From: Michael Niedermayer Date: Sun, 18 Feb 2018 16:12:28 +0000 (+0100) Subject: avcodec/h264_parse: Clear invalid chroma weights in ff_h264_pred_weight_table() X-Git-Tag: n3.3.7~45 X-Git-Url: http://git.videolan.org/gitweb.cgi/ffmpeg.git/?p=ffmpeg.git;p=ffmpeg.git;a=commitdiff_plain;h=4018d8586ffe1fc8d5f7f28df6c010c748d3fb75;hp=b172815c3c9bb7dcaa88e388418bbbefd5aa978e avcodec/h264_parse: Clear invalid chroma weights in ff_h264_pred_weight_table() Fixes: 6037/clusterfuzz-testcase-minimized-5030249784934400 Fixes: signed integer overflow: 256 * 16992036 cannot be represented in type 'int' Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer (cherry picked from commit 85c85fffff3f9c75301db3eba1bd5f2fb1e6285d) Signed-off-by: Michael Niedermayer --- diff --git a/libavcodec/h264_parse.c b/libavcodec/h264_parse.c index a7c71d9bbb..dfc57076d1 100644 --- a/libavcodec/h264_parse.c +++ b/libavcodec/h264_parse.c @@ -82,8 +82,11 @@ int ff_h264_pred_weight_table(GetBitContext *gb, const SPS *sps, pwt->chroma_weight[i][list][j][0] = get_se_golomb(gb); pwt->chroma_weight[i][list][j][1] = get_se_golomb(gb); if ((int8_t)pwt->chroma_weight[i][list][j][0] != pwt->chroma_weight[i][list][j][0] || - (int8_t)pwt->chroma_weight[i][list][j][1] != pwt->chroma_weight[i][list][j][1]) + (int8_t)pwt->chroma_weight[i][list][j][1] != pwt->chroma_weight[i][list][j][1]) { + pwt->chroma_weight[i][list][j][0] = chroma_def; + pwt->chroma_weight[i][list][j][1] = 0; goto out_range_weight; + } if (pwt->chroma_weight[i][list][j][0] != chroma_def || pwt->chroma_weight[i][list][j][1] != 0) { pwt->use_weight_chroma = 1;