X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fhuffyuvdec.c;h=46dcfa823543c15f2a4569c57cda785d3531b205;hb=0f0f5188acc67a35a8f045505ccf6e2178e5f858;hp=dfe3585e6e6e78826a864b03e27e75dbcf7965e9;hpb=96e495082aedc4fcf444e2c7ef301867ba3e0b1f;p=ffmpeg diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c index dfe3585e6e6..46dcfa82354 100644 --- a/libavcodec/huffyuvdec.c +++ b/libavcodec/huffyuvdec.c @@ -418,9 +418,6 @@ static av_cold int decode_init(AVCodecContext *avctx) case 0x0F0: avctx->pix_fmt = AV_PIX_FMT_GRAY16; break; - case 0x170: - avctx->pix_fmt = AV_PIX_FMT_GRAY8A; - break; case 0x470: avctx->pix_fmt = AV_PIX_FMT_GBRP; break; @@ -1254,7 +1251,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, slices_info_offset = AV_RL32(avpkt->data + buf_size - 4); slice_height = AV_RL32(avpkt->data + buf_size - 8); nb_slices = AV_RL32(avpkt->data + buf_size - 12); - if (nb_slices * 8LL + slices_info_offset > buf_size - 16 || slice_height <= 0) + if (nb_slices * 8LL + slices_info_offset > buf_size - 16 || + s->chroma_v_shift || + slice_height <= 0 || nb_slices * (uint64_t)slice_height > height) return AVERROR_INVALIDDATA; } else { slice_height = height; @@ -1267,6 +1266,11 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, if (nb_slices > 1) { slice_offset = AV_RL32(avpkt->data + slices_info_offset + slice * 8); slice_size = AV_RL32(avpkt->data + slices_info_offset + slice * 8 + 4); + + if (slice_offset < 0 || slice_size <= 0 || (slice_offset&3) || + slice_offset + (int64_t)slice_size > buf_size) + return AVERROR_INVALIDDATA; + y_offset = height - (slice + 1) * slice_height; s->bdsp.bswap_buf((uint32_t *)s->bitstream_buffer, (const uint32_t *)(buf + slice_offset), slice_size / 4);