From: Marton Balint <cus@passwd.hu> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Subject: Re: [FFmpeg-devel] [PATCH 3/4] avformat/mxfdec: Check for avio_read() failure in mxf_read_strong_ref_array() Date: Sun, 13 Mar 2022 16:52:25 +0100 (CET) Message-ID: <1e687354-29fa-6c18-2850-c1fe7da6bd42@passwd.hu> (raw) In-Reply-To: <20220312235227.19626-3-michael@niedermayer.cc> On Sun, 13 Mar 2022, Michael Niedermayer wrote: > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> > --- > libavformat/mxfdec.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c > index d7cdd22c8a..828fc0f9f1 100644 > --- a/libavformat/mxfdec.c > +++ b/libavformat/mxfdec.c > @@ -932,6 +932,7 @@ static int mxf_read_cryptographic_context(void *arg, AVIOContext *pb, int tag, i > > static int mxf_read_strong_ref_array(AVIOContext *pb, UID **refs, int *count) > { > + int64_t ret; > unsigned c = avio_rb32(pb); > > //avio_read() used int > @@ -946,7 +947,12 @@ static int mxf_read_strong_ref_array(AVIOContext *pb, UID **refs, int *count) > return AVERROR(ENOMEM); > } > avio_skip(pb, 4); /* useless size of objects, always 16 according to specs */ > - avio_read(pb, (uint8_t *)*refs, *count * sizeof(UID)); > + ret = avio_read(pb, (uint8_t *)*refs, *count * sizeof(UID)); > + if (ret != *count * sizeof(UID)) { > + *count = ret < 0 ? 0 : ret / sizeof(UID); I suggest you hard fail if the read count is not the expected, do not silently ignore corrupt file. Regards, Marton > + return ret < 0 ? ret : AVERROR_INVALIDDATA; > + } > + > return 0; > } > > -- > 2.17.1 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". > _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2022-03-13 15:52 UTC|newest] Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-03-12 23:52 [FFmpeg-devel] [PATCH 1/4] avcodec/vp9_superframe_split_bsf: Check in size Michael Niedermayer 2022-03-12 23:52 ` [FFmpeg-devel] [PATCH 2/4] avformat/mxfdec: Check count in mxf_read_strong_ref_array() Michael Niedermayer 2022-03-14 19:19 ` Tomas Härdin 2022-03-19 22:50 ` Michael Niedermayer 2022-03-20 13:05 ` Tomas Härdin 2022-03-20 14:06 ` Michael Niedermayer 2022-03-21 10:06 ` Tomas Härdin 2022-03-21 21:20 ` Michael Niedermayer 2022-03-12 23:52 ` [FFmpeg-devel] [PATCH 3/4] avformat/mxfdec: Check for avio_read() failure " Michael Niedermayer 2022-03-13 15:52 ` Marton Balint [this message] 2022-03-14 13:58 ` Michael Niedermayer 2022-03-14 17:08 ` Marton Balint 2022-03-15 12:48 ` Michael Niedermayer 2022-03-14 19:21 ` Tomas Härdin 2022-03-19 22:54 ` Michael Niedermayer 2022-03-12 23:52 ` [FFmpeg-devel] [PATCH 4/4] avformat/mxfdec: Do not clear array in mxf_read_strong_ref_array() before writing Michael Niedermayer 2022-03-13 15:53 ` Marton Balint 2022-03-14 13:59 ` Michael Niedermayer 2022-03-13 19:03 ` [FFmpeg-devel] [PATCH 1/4] avcodec/vp9_superframe_split_bsf: Check in size James Almer 2022-03-14 14:04 ` Michael Niedermayer 2022-03-14 14:07 ` James Almer 2022-03-14 14:16 ` Michael Niedermayer 2022-03-21 18:59 ` Michael Niedermayer
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1e687354-29fa-6c18-2850-c1fe7da6bd42@passwd.hu \ --to=cus@passwd.hu \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git