diff options
author | Michael Niedermayer <[email protected]> | 2012-11-09 20:58:57 +0100 |
---|---|---|
committer | Michael Niedermayer <[email protected]> | 2012-12-03 20:44:30 +0100 |
commit | 112d4c400f0e0d5d1621fc8db515907cffaae259 (patch) | |
tree | 2f3bf0f2349e93e95b3233dfae2f8cf11a048397 | |
parent | 0b9be54e97fa574867d5e99a3623d1db7df7b274 (diff) |
iff/ilbm: check remaining buffer size.
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <[email protected]>
(cherry picked from commit 2fbb37b51bbea891392ad357baf8f3dff00bac05)
Conflicts:
libavcodec/iff.c
-rw-r--r-- | libavcodec/iff.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libavcodec/iff.c b/libavcodec/iff.c index 2c4ea8f8e6..08360d5c18 100644 --- a/libavcodec/iff.c +++ b/libavcodec/iff.c @@ -562,13 +562,13 @@ static int decode_frame_ilbm(AVCodecContext *avctx, } } else if (avctx->codec_tag == MKTAG('P','B','M',' ')) { // IFF-PBM if (avctx->pix_fmt == PIX_FMT_PAL8 || avctx->pix_fmt == PIX_FMT_GRAY8) { - for(y = 0; y < avctx->height; y++ ) { + for(y = 0; y < avctx->height && buf_end > buf; y++ ) { uint8_t *row = &s->frame.data[0][y * s->frame.linesize[0]]; memcpy(row, buf, FFMIN(avctx->width, buf_end - buf)); buf += avctx->width + (avctx->width % 2); // padding if odd } } else if (s->ham) { // IFF-PBM: HAM to PIX_FMT_BGR32 - for (y = 0; y < avctx->height; y++) { + for (y = 0; y < avctx->height && buf_end > buf; y++) { uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ]; memcpy(s->ham_buf, buf, FFMIN(avctx->width, buf_end - buf)); buf += avctx->width + (avctx->width & 1); // padding if odd |