1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-01-13 21:28:01 +02:00

avcodec/fitsdec: Check data_min/max

Fixes: division by 0
Fixes: 15206/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FITS_fuzzer-5657260212092928

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 eb82d19f03)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2019-06-13 00:24:53 +02:00
parent 2248084e8f
commit 8819aa775b

View File

@ -168,6 +168,14 @@ static int fits_read_header(AVCodecContext *avctx, const uint8_t **ptr, FITSHead
header->data_min = (header->data_min - header->bzero) / header->bscale;
header->data_max = (header->data_max - header->bzero) / header->bscale;
}
if (!header->rgb && header->data_min >= header->data_max) {
if (header->data_min > header->data_max) {
av_log(avctx, AV_LOG_ERROR, "data min/max (%g %g) is invalid\n", header->data_min, header->data_max);
return AVERROR_INVALIDDATA;
}
av_log(avctx, AV_LOG_WARNING, "data min/max indicates a blank image\n");
header->data_max ++;
}
return 0;
}