1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avcodec/tiff: Fix default white level

According to the spec bits per sample should be used

Fix invalid shift with bpp=32
Fixes: shift exponent 32 is too large for 32-bit type 'unsigned int'
Fixes: 23507/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-4815432665268224

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2020-07-16 22:42:14 +02:00
parent ca3c6c981a
commit d54c24acde

View File

@ -1895,8 +1895,14 @@ again:
if (is_dng) { if (is_dng) {
int bps; int bps;
if (s->bpp % s->bppcount)
return AVERROR_INVALIDDATA;
bps = s->bpp / s->bppcount;
if (bps < 8 || bps > 32)
return AVERROR_INVALIDDATA;
if (s->white_level == 0) if (s->white_level == 0)
s->white_level = (1 << s->bpp) - 1; /* Default value as per the spec */ s->white_level = (1LL << bps) - 1; /* Default value as per the spec */
if (s->white_level <= s->black_level) { if (s->white_level <= s->black_level) {
av_log(avctx, AV_LOG_ERROR, "BlackLevel (%"PRId32") must be less than WhiteLevel (%"PRId32")\n", av_log(avctx, AV_LOG_ERROR, "BlackLevel (%"PRId32") must be less than WhiteLevel (%"PRId32")\n",
@ -1904,11 +1910,6 @@ again:
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
if (s->bpp % s->bppcount)
return AVERROR_INVALIDDATA;
bps = s->bpp / s->bppcount;
if (bps < 8 || bps > 32)
return AVERROR_INVALIDDATA;
if (s->planar) if (s->planar)
return AVERROR_PATCHWELCOME; return AVERROR_PATCHWELCOME;
} }