diff mbox series

[FFmpeg-devel,03/13] avformat/nutdec: Check fields

Message ID 20220918171410.31835-3-michael@niedermayer.cc
State Accepted
Commit 2c146406eac06f3d3cd3d981c29e7affd834cb4d
Headers show
Series [FFmpeg-devel,01/13] avformat/flvdec: Use 64bit for sum_flv_tag_size | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Michael Niedermayer Sept. 18, 2022, 5:14 p.m. UTC
Fixes: signed integer overflow: -2147483648 - 1 cannot be represented in type 'int'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_NUT_fuzzer-6566001610719232

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavformat/nutdec.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
index 8cc56615ad7..24dedc47582 100644
--- a/libavformat/nutdec.c
+++ b/libavformat/nutdec.c
@@ -245,6 +245,11 @@  static int decode_main_header(NUTContext *nut)
     for (i = 0; i < 256;) {
         int tmp_flags  = ffio_read_varlen(bc);
         int tmp_fields = ffio_read_varlen(bc);
+        if (tmp_fields < 0) {
+            av_log(s, AV_LOG_ERROR, "fields %d is invalid\n", tmp_fields);
+            ret = AVERROR_INVALIDDATA;
+            goto fail;
+        }
 
         if (tmp_fields > 0)
             tmp_pts = get_s(bc);