X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Ffitsdec.c;h=4f452422efd60783a59fe809c649dfb7a55b62c3;hb=0f0f5188acc67a35a8f045505ccf6e2178e5f858;hp=b0753813c9c92419b6318d5787b13132f1fbc19f;hpb=4dc1f06f0c84ebbd8b26cd77679450903244a3e8;p=ffmpeg diff --git a/libavcodec/fitsdec.c b/libavcodec/fitsdec.c index b0753813c9c..4f452422efd 100644 --- a/libavcodec/fitsdec.c +++ b/libavcodec/fitsdec.c @@ -143,7 +143,7 @@ static int fits_read_header(AVCodecContext *avctx, const uint8_t **ptr, FITSHead size = abs(header->bitpix) >> 3; for (i = 0; i < header->naxis; i++) { - if (header->naxisn[i] > SIZE_MAX / size) { + if (size && header->naxisn[i] > SIZE_MAX / size) { av_log(avctx, AV_LOG_ERROR, "unsupported size of FITS image"); return AVERROR_INVALIDDATA; } @@ -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; }