diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2019-06-05 12:18:54 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2020-07-01 12:11:55 +0200 |
commit | 804f68d91eaeed80494c6cef7e232e34fd873e6e (patch) | |
tree | 32900861f12750729e2ad968a0d6aab68f1b308f | |
parent | 9e1fcf4975889343a65555746806165dc89e7200 (diff) | |
download | ffmpeg-804f68d91eaeed80494c6cef7e232e34fd873e6e.tar.gz |
avcodec/bitstream: Check for more conflicting codes in build_table()
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>
(cherry picked from commit a7e3b271fc9a91c5d2e4df32e70e525c15c6d3ef)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavcodec/bitstream.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/libavcodec/bitstream.c b/libavcodec/bitstream.c index c14081139d..fc520a6143 100644 --- a/libavcodec/bitstream.c +++ b/libavcodec/bitstream.c @@ -195,8 +195,9 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, } for (k = 0; k < nb; k++) { int bits = table[j][1]; + int oldsym = table[j][0]; ff_dlog(NULL, "%4x: code=%d n=%d\n", j, i, n); - if (bits != 0 && bits != n) { + if ((bits || oldsym) && (bits != n || oldsym != symbol)) { av_log(NULL, AV_LOG_ERROR, "incorrect codes\n"); return AVERROR_INVALIDDATA; } |