summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorCarl Eugen Hoyos <ceffmpeg@gmail.com>2019-03-26 13:32:11 +0100
committerCarl Eugen Hoyos <ceffmpeg@gmail.com>2019-03-26 21:07:51 +0100
commit1e34014010dba9325fc5430934b51a61a5007c63 (patch)
tree1653facaaa464b8e33fde96abb8ddc16291c17d9 /libavcodec
parente9c9514ce37ce21a91b2a67cecd1457b11c0f21c (diff)
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.
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/bmp.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libavcodec/bmp.c b/libavcodec/bmp.c
index 65d239e4f8..40010ac46f 100644
--- a/libavcodec/bmp.c
+++ b/libavcodec/bmp.c
@@ -291,7 +291,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;
@@ -301,6 +301,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;
}