mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-13 21:28:01 +02:00
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 67b30decf7
)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
586e00d7d3
commit
b419c7564c
@ -109,7 +109,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;
|
||||
|
||||
@ -133,6 +133,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;
|
||||
|
Loading…
Reference in New Issue
Block a user