summaryrefslogtreecommitdiff
path: root/libavcodec/gifdec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-10-03 20:15:52 +0200
committerAnton Khirnov <anton@khirnov.net>2014-12-19 08:01:47 +0100
commit0b39ac6f54505a538c21fe49a626de94c518c903 (patch)
treed66a98d217c4b5e5ba58591a7d1131d78ae9563f /libavcodec/gifdec.c
parent17ba719d9ba30c970f65747f42d5fbb1e447ca28 (diff)
gifdec: refactor interleave end handling
Fixes invalid writes with very small image heights. CC: libav-stable@libav.org Bug-ID: CVE-2014-8547 Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Anton Khirnov <anton@khirnov.net>
Diffstat (limited to 'libavcodec/gifdec.c')
-rw-r--r--libavcodec/gifdec.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/libavcodec/gifdec.c b/libavcodec/gifdec.c
index cdb7f23fd4..df5ab78aba 100644
--- a/libavcodec/gifdec.c
+++ b/libavcodec/gifdec.c
@@ -125,26 +125,21 @@ static int gif_read_image(GifState *s, AVFrame *frame)
case 1:
y1 += 8;
ptr += linesize * 8;
- if (y1 >= height) {
- y1 = pass ? 2 : 4;
- ptr = ptr1 + linesize * y1;
- pass++;
- }
break;
case 2:
y1 += 4;
ptr += linesize * 4;
- if (y1 >= height) {
- y1 = 1;
- ptr = ptr1 + linesize;
- pass++;
- }
break;
case 3:
y1 += 2;
ptr += linesize * 2;
break;
}
+ while (y1 >= height) {
+ y1 = 4 >> pass;
+ ptr = ptr1 + linesize * y1;
+ pass++;
+ }
} else {
ptr += linesize;
}