Skip to content

Commit 1dde2ac

Browse files
committed
Fix bug #77988 - heap-buffer-overflow on php_jpg_get16
1 parent b1aafcb commit 1dde2ac

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

ext/exif/exif.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3540,6 +3540,8 @@ static int exif_scan_thumbnail(image_info_type *ImageInfo TSRMLS_DC)
35403540
if (c == 0xFF)
35413541
return FALSE;
35423542
marker = c;
3543+
if (pos>=ImageInfo->Thumbnail.size)
3544+
return FALSE;
35433545
length = php_jpg_get16(data+pos);
35443546
if (length > ImageInfo->Thumbnail.size || pos >= ImageInfo->Thumbnail.size - length) {
35453547
return FALSE;

ext/exif/tests/bug77988.jpg

1.17 KB
Loading

ext/exif/tests/bug77988.phpt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
Bug #77988 (heap-buffer-overflow on php_jpg_get16)
3+
--SKIPIF--
4+
<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?>
5+
--FILE--
6+
<?php
7+
exif_read_data(__DIR__."/bug77988.jpg", 'COMMENT', FALSE, TRUE);
8+
?>
9+
DONE
10+
--EXPECTF--
11+
DONE

0 commit comments

Comments
 (0)