com php-src: Fix bug #76423 - Int Overflow lead to Heap OverFlow in exif_thumbnail_extract of exif.c: ext/exif/exif .c ext/exif/tests/bug76423.jpg
ext/exif/tests /bug76423.phpt
| From: | Stanislav Malyshev | Date: | Mon, 16 Jul 2018 21:16:58 +0000 |
| Subject: | com php-src: Fix bug #76423 - Int Overflow lead to Heap OverFlow in exif_thumbnail_extract of exif.c: ext/exif/exif .c ext/exif/tests/bug76423.jpg ext/exif/tests /bug76423.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-102563@lists.php.net to get a copy of this message | ||
Commit: 1baeae42703f9b2ec21fff787146eeca08d45535
Author: Stanislav Malyshev <stas@php.net> Tue, 19 Jun 2018 16:26:36 -0700
Parents: fe3d53f4437718fad63850695970dddd63144af5
Branches: PHP-5.6 PHP-7.0 PHP-7.1 PHP-7.2 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=1baeae42703f9b2ec21fff787146eeca08d45535
Log:
Fix bug #76423 - Int Overflow lead to Heap OverFlow in exif_thumbnail_extract of exif.c
Bugs:
https://bugs.php.net/76423
Changed paths:
M ext/exif/exif.c
A ext/exif/tests/bug76423.jpg
A ext/exif/tests/bug76423.phpt
Diff:
diff --git a/ext/exif/exif.c b/ext/exif/exif.c
index e535278..1147980 100644
--- a/ext/exif/exif.c
+++ b/ext/exif/exif.c
@@ -2545,7 +2545,10 @@ static void exif_thumbnail_extract(image_info_type *ImageInfo, char *offset,
siz
return;
}
/* Check to make sure we are not going to go past the ExifLength */
- if ((ImageInfo->Thumbnail.offset + ImageInfo->Thumbnail.size) > length) {
+ if (ImageInfo->Thumbnail.size > length
+ || (ImageInfo->Thumbnail.offset + ImageInfo->Thumbnail.size) > length
+ || ImageInfo->Thumbnail.offset > length - ImageInfo->Thumbnail.size
+ ) {
EXIF_ERRLOG_THUMBEOF(ImageInfo)
return;
}
diff --git a/ext/exif/tests/bug76423.jpg b/ext/exif/tests/bug76423.jpg
new file mode 100644
index 0000000..08fe2bb
Binary files /dev/null and b/ext/exif/tests/bug76423.jpg differ
diff --git a/ext/exif/tests/bug76423.phpt b/ext/exif/tests/bug76423.phpt
new file mode 100644
index 0000000..4c8cd45
--- /dev/null
+++ b/ext/exif/tests/bug76423.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Bug #76423 (Int Overflow lead to Heap OverFlow in exif_thumbnail_extract of exif.c)
+--SKIPIF--
+<?php
+if (!extension_loaded('exif')) die('skip exif extension not available');
+?>
+--FILE--
+<?php
+exif_read_data(__DIR__ . '/bug76423.jpg', 0, true, true);
+?>
+===DONE===
+--EXPECTF--
+
+Warning: exif_read_data(%s.jpg): Thumbnail goes IFD boundary or end of file reached in %s on line
%d
+
+Warning: exif_read_data(%s.jpg): File structure corrupted in %s on line %d
+
+Warning: exif_read_data(%s.jpg): Invalid JPEG file in %s on line %d
+===DONE===