diff mbox series

[FFmpeg-devel,12/15] avformat/westwood_vqa: Do not leave vqfl_chunk_size invalid

Message ID 20230930223046.22896-12-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel,01/15] avformat/concatdec: Check in/outpoint for overflow | 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. 30, 2023, 10:30 p.m. UTC
Fixes: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int'
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_WSVQA_fuzzer-4613908817903616

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

Comments

Michael Niedermayer Sept. 30, 2023, 10:48 p.m. UTC | #1
On Sun, Oct 01, 2023 at 12:30:43AM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int'
> Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_WSVQA_fuzzer-4613908817903616
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavformat/westwood_vqa.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

patch withdrawn, i had written and submitted an alternative patch a year ago
and then forgot to apply it it seems

[...]
diff mbox series

Patch

diff --git a/libavformat/westwood_vqa.c b/libavformat/westwood_vqa.c
index e3d2e2668c4..18948d14ccc 100644
--- a/libavformat/westwood_vqa.c
+++ b/libavformat/westwood_vqa.c
@@ -194,8 +194,10 @@  static int wsvqa_read_packet(AVFormatContext *s,
              * includes a whole frame as expected. */
             wsvqa->vqfl_chunk_pos = avio_tell(pb);
             wsvqa->vqfl_chunk_size = (int)(chunk_size);
-            if (wsvqa->vqfl_chunk_size < 0 || wsvqa->vqfl_chunk_size > 3 * (1 << 20))
+            if (wsvqa->vqfl_chunk_size < 0 || wsvqa->vqfl_chunk_size > 3 * (1 << 20)) {
+                wsvqa->vqfl_chunk_size = 0;
                 return AVERROR_INVALIDDATA;
+            }
             /* We need a big seekback buffer because there can be SNxx, VIEW and ZBUF
              * chunks (<512 KiB total) in the stream before we read VQFR (<256 KiB) and
              * seek back here. */