[FFmpeg-cvslog] avformat/mxfdec: Check for avio_read() failure in mxf_read_strong_ref_array()
Michael Niedermayer
git at videolan.org
Wed Apr 6 22:56:26 EEST 2022
ffmpeg | branch: release/4.3 | Michael Niedermayer <michael at niedermayer.cc> | Sun Mar 13 00:36:55 2022 +0100| [565bb5fe7be9fbf58b98654684cfed08e43f1fdf] | committer: Michael Niedermayer
avformat/mxfdec: Check for avio_read() failure in mxf_read_strong_ref_array()
Fixes: 42827/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-4900528511909888
Reviewed-by: Tomas Härdin <tjoppen at acc.umu.se>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit 8d6f49cfc339825f3f3f8a910e4bb4c0f822db1f)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=565bb5fe7be9fbf58b98654684cfed08e43f1fdf
---
libavformat/mxfdec.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 9e52e60595..34e4cc984b 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -852,6 +852,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
@@ -866,7 +867,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);
+ return ret < 0 ? ret : AVERROR_INVALIDDATA;
+ }
+
return 0;
}
More information about the ffmpeg-cvslog
mailing list