diff mbox series

[FFmpeg-devel] avcodec/snappy: Sanity check bytestream2_get_levarint()

Message ID 20200120000746.8540-1-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel] avcodec/snappy: Sanity check bytestream2_get_levarint()
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Michael Niedermayer Jan. 20, 2020, 12:07 a.m. UTC
Fixes: left shift of 79 by 28 places cannot be represented in type 'int'
Fixes: 20202/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HAP_fuzzer-5719004081815552
Fixes: 20219/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HAP_fuzzer-5641738677125120

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

Comments

Michael Niedermayer Feb. 2, 2020, 10:55 p.m. UTC | #1
On Mon, Jan 20, 2020 at 01:07:46AM +0100, Michael Niedermayer wrote:
> Fixes: left shift of 79 by 28 places cannot be represented in type 'int'
> Fixes: 20202/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HAP_fuzzer-5719004081815552
> Fixes: 20219/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HAP_fuzzer-5641738677125120
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/snappy.c | 2 ++
>  1 file changed, 2 insertions(+)

will apply

[...]
diff mbox series

Patch

diff --git a/libavcodec/snappy.c b/libavcodec/snappy.c
index 7900b0f978..f5c4c6578b 100644
--- a/libavcodec/snappy.c
+++ b/libavcodec/snappy.c
@@ -39,6 +39,8 @@  static int64_t bytestream2_get_levarint(GetByteContext *gb)
 
     do {
         tmp = bytestream2_get_byte(gb);
+        if (shift > 31 || ((tmp & 127LL) << shift) > INT_MAX)
+            return AVERROR_INVALIDDATA;
         val |= (tmp & 127) << shift;
         shift += 7;
     } while (tmp & 128);