mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
avcodec/pnm: Check that the header is not truncated
Fixes: Ticket8430
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c94cb8d9b2
)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
8bdb8b5689
commit
4b521929cf
@ -108,6 +108,9 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s)
|
|||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!pnm_space(s->bytestream[-1]))
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
/* check that all tags are present */
|
/* check that all tags are present */
|
||||||
if (w <= 0 || h <= 0 || maxval <= 0 || maxval > UINT16_MAX || depth <= 0 || tuple_type[0] == '\0' ||
|
if (w <= 0 || h <= 0 || maxval <= 0 || maxval > UINT16_MAX || depth <= 0 || tuple_type[0] == '\0' ||
|
||||||
av_image_check_size(w, h, 0, avctx) || s->bytestream >= s->bytestream_end)
|
av_image_check_size(w, h, 0, avctx) || s->bytestream >= s->bytestream_end)
|
||||||
@ -188,6 +191,10 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s)
|
|||||||
}
|
}
|
||||||
}else
|
}else
|
||||||
s->maxval=1;
|
s->maxval=1;
|
||||||
|
|
||||||
|
if (!pnm_space(s->bytestream[-1]))
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
/* more check if YUV420 */
|
/* more check if YUV420 */
|
||||||
if (av_pix_fmt_desc_get(avctx->pix_fmt)->flags & AV_PIX_FMT_FLAG_PLANAR) {
|
if (av_pix_fmt_desc_get(avctx->pix_fmt)->flags & AV_PIX_FMT_FLAG_PLANAR) {
|
||||||
if ((avctx->width & 1) != 0)
|
if ((avctx->width & 1) != 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user