diff options
author | Kostya Shishkov <kostya.shishkov@gmail.com> | 2008-11-24 11:24:02 +0000 |
---|---|---|
committer | Kostya Shishkov <kostya.shishkov@gmail.com> | 2008-11-24 11:24:02 +0000 |
commit | c5b2fe165a31f0319d55a14a92cbac2e0e0b95fc (patch) | |
tree | b2490ccfc9cbe494ed1715df6b2b9ebec14fdba1 /libavcodec/bmp.c | |
parent | e282307b21b25a62a5b814e3848fe8a002565bb0 (diff) | |
download | ffmpeg-c5b2fe165a31f0319d55a14a92cbac2e0e0b95fc.tar.gz |
Some BMP files have file size declared in the header equal to headers size
without image data, so try to correct that value before conducting checks on
declared file size.
Originally committed as revision 15924 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/bmp.c')
-rw-r--r-- | libavcodec/bmp.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/libavcodec/bmp.c b/libavcodec/bmp.c index 23837bd15a..9a20cd6c97 100644 --- a/libavcodec/bmp.c +++ b/libavcodec/bmp.c @@ -73,18 +73,22 @@ static int bmp_decode_frame(AVCodecContext *avctx, buf += 2; /* reserved2 */ hsize = bytestream_get_le32(&buf); /* header size */ - if(fsize <= hsize){ - av_log(avctx, AV_LOG_ERROR, "declared file size is less than header size (%d < %d)\n", - fsize, hsize); - return -1; - } - ihsize = bytestream_get_le32(&buf); /* more header size */ if(ihsize + 14 > hsize){ av_log(avctx, AV_LOG_ERROR, "invalid header size %d\n", hsize); return -1; } + /* sometimes file size is set to some headers size, set a real size in that case */ + if(fsize == 14 || fsize == ihsize + 14) + fsize = buf_size - 2; + + if(fsize <= hsize){ + av_log(avctx, AV_LOG_ERROR, "declared file size is less than header size (%d < %d)\n", + fsize, hsize); + return -1; + } + switch(ihsize){ case 40: // windib v3 case 64: // OS/2 v2 |