[FFmpeg-devel,1/2] avcodec/bitstream: Check for integer code truncation in build_table()

Submitted by Michael Niedermayer on June 5, 2019, 10:55 a.m.

Details

Message ID 20190605105517.24005-1-michael@niedermayer.cc
State Accepted
Commit e78b0f83748f92ea9e93b21c36082e0dd04d7cb1
Headers show

Commit Message

Michael Niedermayer June 5, 2019, 10:55 a.m.
Fixes: out of array read
Fixes: 14563/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AGM_fuzzer-5646451545210880

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

Comments

Michael Niedermayer June 13, 2019, 10:04 p.m.
On Wed, Jun 05, 2019 at 12:55:16PM +0200, Michael Niedermayer wrote:
> Fixes: out of array read
> Fixes: 14563/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AGM_fuzzer-5646451545210880
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/bitstream.c | 4 ++++
>  1 file changed, 4 insertions(+)

will apply patchset

[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/bitstream.c b/libavcodec/bitstream.c
index 8762e5f4b2..590b490527 100644
--- a/libavcodec/bitstream.c
+++ b/libavcodec/bitstream.c
@@ -226,6 +226,10 @@  static int build_table(VLC *vlc, int table_nb_bits, int nb_codes,
             /* note: realloc has been done, so reload tables */
             table = (volatile VLC_TYPE (*)[2])&vlc->table[table_index];
             table[j][0] = index; //code
+            if (table[j][0] != index) {
+                avpriv_request_sample(NULL, "strange codes");
+                return AVERROR_PATCHWELCOME;
+            }
             i = k-1;
         }
     }