[FFmpeg-cvslog] lavc/bmp: Avoid a heap buffer overwrite for 1bpp input.
Carl Eugen Hoyos
git at videolan.org
Fri May 10 22:03:13 EEST 2019
ffmpeg | branch: release/3.2 | Carl Eugen Hoyos <ceffmpeg at gmail.com> | Tue Mar 26 13:32:11 2019 +0100| [0eeea04a7170040cd5035e0ab2acc546815886ce] | committer: Michael Niedermayer
lavc/bmp: Avoid a heap buffer overwrite for 1bpp input.
Found by Mingi Cho, Seoyoung Kim, and Taekyoung Kwon
of the Information Security Lab, Yonsei University.
(cherry picked from commit 1e34014010dba9325fc5430934b51a61a5007c63)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0eeea04a7170040cd5035e0ab2acc546815886ce
---
libavcodec/bmp.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/libavcodec/bmp.c b/libavcodec/bmp.c
index fa1d6a53f2..a181671ab1 100644
--- a/libavcodec/bmp.c
+++ b/libavcodec/bmp.c
@@ -286,7 +286,7 @@ static int bmp_decode_frame(AVCodecContext *avctx,
case 1:
for (i = 0; i < avctx->height; i++) {
int j;
- for (j = 0; j < n; j++) {
+ for (j = 0; j < avctx->width >> 3; j++) {
ptr[j*8+0] = buf[j] >> 7;
ptr[j*8+1] = (buf[j] >> 6) & 1;
ptr[j*8+2] = (buf[j] >> 5) & 1;
@@ -296,6 +296,9 @@ static int bmp_decode_frame(AVCodecContext *avctx,
ptr[j*8+6] = (buf[j] >> 1) & 1;
ptr[j*8+7] = buf[j] & 1;
}
+ for (j = 0; j < (avctx->width & 7); j++) {
+ ptr[avctx->width - (avctx->width & 7) + j] = buf[avctx->width >> 3] >> (7 - j) & 1;
+ }
buf += n;
ptr += linesize;
}
More information about the ffmpeg-cvslog
mailing list