aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2022-03-13 00:36:55 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2022-03-21 22:27:14 +0100
commit8d6f49cfc339825f3f3f8a910e4bb4c0f822db1f (patch)
tree702089104bbf9eec0cbd4fac1e2721fe6499beca /libavformat
parent3015c556f316d4ab364ed55e8bc97cc0f2cc57a3 (diff)
downloadffmpeg-8d6f49cfc339825f3f3f8a910e4bb4c0f822db1f.tar.gz
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@acc.umu.se> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/mxfdec.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index a858bbb7be..49ed02185f 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -933,6 +933,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
@@ -947,7 +948,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;
}