diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2017-05-28 17:20:42 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2017-06-18 16:05:23 +0200 |
commit | 41c6624c885c8ff0a921118b9d8af680d7acee4c (patch) | |
tree | de7b2c62b1ba9731533b7c30fdd6f9aef544ae98 | |
parent | b778eb8d64c2143eef04d470e76f2a701bdc2b32 (diff) | |
download | ffmpeg-41c6624c885c8ff0a921118b9d8af680d7acee4c.tar.gz |
avcodec/ylc: Check count in build_vlc()
Fixes: runtime error: signed integer overflow: 211633430 + 2147483647 cannot be represented in type 'int'
Fixes: 1874/clusterfuzz-testcase-minimized-5037763613163520
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 67b30decf7793523f7fdaef6fdf7f1179ef42b18)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavcodec/ylc.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libavcodec/ylc.c b/libavcodec/ylc.c index 95a5e05baa..1af880f4d4 100644 --- a/libavcodec/ylc.c +++ b/libavcodec/ylc.c @@ -108,7 +108,7 @@ static int build_vlc(AVCodecContext *avctx, VLC *vlc, const uint32_t *table) int new_node = j; int first_node = cur_node; int second_node = cur_node; - int nd, st; + unsigned nd, st; nodes[cur_node].count = -1; @@ -132,6 +132,10 @@ static int build_vlc(AVCodecContext *avctx, VLC *vlc, const uint32_t *table) st = nodes[first_node].count; nodes[second_node].count = 0; nodes[first_node].count = 0; + if (nd >= UINT32_MAX - st) { + av_log(avctx, AV_LOG_ERROR, "count overflow\n"); + return AVERROR_INVALIDDATA; + } nodes[cur_node].count = nd + st; nodes[cur_node].sym = -1; nodes[cur_node].n0 = cur_node; |