1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

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.
This commit is contained in:
Carl Eugen Hoyos 2019-03-26 13:32:11 +01:00
parent e9c9514ce3
commit 1e34014010

View File

@ -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;
}