]> granicus.if.org Git - php/commitdiff
Fix bug #77950 - Heap-buffer-overflow in _estrndup via exif_process_IFD_TAG
authorStanislav Malyshev <stas@php.net>
Tue, 30 Apr 2019 06:38:12 +0000 (23:38 -0700)
committerStanislav Malyshev <stas@php.net>
Tue, 30 Apr 2019 07:05:23 +0000 (00:05 -0700)
I do not completely understand what is going on there, but I am pretty
sure dir_entry <= offset_base if not a normal situation, so we better not
to rely on such dir_entry.

NEWS
ext/exif/exif.c
ext/exif/tests/bug77950.phpt [new file with mode: 0644]
ext/exif/tests/bug77950.tiff [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index f529a71116cc53f24a7a8b8e2d1e018877925f23..70ad9a7a6fb340fcfc72b86cf09e6ce51cbfed21 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,13 +2,20 @@ PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? 2019, PHP 7.1.29
 
+- EXIF
+. Fixed bug #77950 (Heap-buffer-overflow in _estrndup via exif_process_IFD_TAG). 
+  (CVE-2019-11036) (Stas)
 
+- Mail
+. Fixed bug #77821 (Potential heap corruption in TSendMail()). (cmb)
 
 04 Apr 2019, PHP 7.1.28
 
 - EXIF:
-  . Fixed bug #77753 (Heap-buffer-overflow in php_ifd_get32s). (Stas)
-  . Fixed bug #77831 (Heap-buffer-overflow in exif_iif_add_value). (Stas)
+  . Fixed bug #77753 (Heap-buffer-overflow in php_ifd_get32s). (CVE-2019-11034)
+    (Stas)
+  . Fixed bug #77831 (Heap-buffer-overflow in exif_iif_add_value). 
+       (CVE-2019-11035) (Stas)
 
 - SQLite3:
   . Added sqlite3.defensive INI directive. (BohwaZ)
index a763f6c77b0d1664eadc924e650181850843f72d..d174def80c1355fc54d09a0ae754ced64d85768d 100644 (file)
@@ -2891,7 +2891,7 @@ static int exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, cha
             offset_base is ImageInfo->file.list[sn].data-dir_offset
             dir_entry - offset_base is dir_offset+2+i*12
         */
-               if (byte_count > IFDlength || offset_val > IFDlength-byte_count || value_ptr < dir_entry || offset_val < (size_t)(dir_entry-offset_base)) {
+               if (byte_count > IFDlength || offset_val > IFDlength-byte_count || value_ptr < dir_entry || offset_val < (size_t)(dir_entry-offset_base) || dir_entry <= offset_base) {
                        /* It is important to check for IMAGE_FILETYPE_TIFF
                         * JPEG does not use absolute pointers instead its pointers are
                         * relative to the start of the TIFF header in APP1 section. */
diff --git a/ext/exif/tests/bug77950.phpt b/ext/exif/tests/bug77950.phpt
new file mode 100644 (file)
index 0000000..dc0f354
--- /dev/null
@@ -0,0 +1,12 @@
+--TEST--
+Bug #77950 (Heap-buffer-overflow in _estrndup via exif_process_IFD_TAG)
+--SKIPIF--
+<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?>
+--FILE--
+<?php
+exif_read_data(__DIR__."/bug77950.tiff");
+?>
+DONE
+--EXPECTF--
+%A
+DONE
\ No newline at end of file
diff --git a/ext/exif/tests/bug77950.tiff b/ext/exif/tests/bug77950.tiff
new file mode 100644 (file)
index 0000000..5c8250a
Binary files /dev/null and b/ext/exif/tests/bug77950.tiff differ