X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fiff.c;h=57ce570957f7663b33507b5fb0e6aae764bf752f;hb=17352ad3155a64683613c8086f558599445aa3c7;hp=0a4a983955c892c9a4fd937a0c82b70f59bb02ee;hpb=41abc9da50ba7a7b68bbbf6622475ce7a3c72e3f;p=ffmpeg diff --git a/libavcodec/iff.c b/libavcodec/iff.c index 0a4a983955c..57ce570957f 100644 --- a/libavcodec/iff.c +++ b/libavcodec/iff.c @@ -191,7 +191,13 @@ static int extract_header(AVCodecContext *const avctx, const uint8_t *buf; unsigned buf_size; IffContext *s = avctx->priv_data; - int palette_size = avctx->extradata_size - AV_RB16(avctx->extradata); + int palette_size; + + if (avctx->extradata_size < 2) { + av_log(avctx, AV_LOG_ERROR, "not enough extradata\n"); + return AVERROR_INVALIDDATA; + } + palette_size = avctx->extradata_size - AV_RB16(avctx->extradata); if (avpkt) { int image_size; @@ -207,8 +213,6 @@ static int extract_header(AVCodecContext *const avctx, return AVERROR_INVALIDDATA; } } else { - if (avctx->extradata_size < 2) - return AVERROR_INVALIDDATA; buf = avctx->extradata; buf_size = bytestream_get_be16(&buf); if (buf_size <= 1 || palette_size < 0) { @@ -312,7 +316,12 @@ static av_cold int decode_init(AVCodecContext *avctx) int err; if (avctx->bits_per_coded_sample <= 8) { - int palette_size = avctx->extradata_size - AV_RB16(avctx->extradata); + int palette_size; + + if (avctx->extradata_size >= 2) + palette_size = avctx->extradata_size - AV_RB16(avctx->extradata); + else + palette_size = 0; avctx->pix_fmt = (avctx->bits_per_coded_sample < 8) || (avctx->extradata_size >= 2 && palette_size) ? PIX_FMT_PAL8 : PIX_FMT_GRAY8; } else if (avctx->bits_per_coded_sample <= 32) { @@ -674,6 +683,7 @@ static av_cold int decode_end(AVCodecContext *avctx) return 0; } +#if CONFIG_IFF_ILBM_DECODER AVCodec ff_iff_ilbm_decoder = { .name = "iff_ilbm", .type = AVMEDIA_TYPE_VIDEO, @@ -685,7 +695,8 @@ AVCodec ff_iff_ilbm_decoder = { .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("IFF ILBM"), }; - +#endif +#if CONFIG_IFF_BYTERUN1_DECODER AVCodec ff_iff_byterun1_decoder = { .name = "iff_byterun1", .type = AVMEDIA_TYPE_VIDEO, @@ -697,3 +708,4 @@ AVCodec ff_iff_byterun1_decoder = { .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("IFF ByteRun1"), }; +#endif