[FFmpeg-cvslog] iff/ilbm: check remaining buffer size.

Michael Niedermayer git at videolan.org
Fri Nov 9 21:07:01 CET 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Fri Nov  9 20:58:57 2012 +0100| [2fbb37b51bbea891392ad357baf8f3dff00bac05] | committer: Michael Niedermayer

iff/ilbm: check remaining buffer size.

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2fbb37b51bbea891392ad357baf8f3dff00bac05
---

 libavcodec/iff.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/iff.c b/libavcodec/iff.c
index d5c1457..9184015 100644
--- a/libavcodec/iff.c
+++ b/libavcodec/iff.c
@@ -575,13 +575,13 @@ static int decode_frame_ilbm(AVCodecContext *avctx,
         }
     } else if (avctx->codec_tag == MKTAG('P','B','M',' ')) { // IFF-PBM
         if (avctx->pix_fmt == AV_PIX_FMT_PAL8 || avctx->pix_fmt == AV_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 AV_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



More information about the ffmpeg-cvslog mailing list