Skip to content

Commit f80ad18

Browse files
committed
Fix bug #77950 - Heap-buffer-overflow in _estrndup via exif_process_IFD_TAG
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.
1 parent 6c631cc commit f80ad18

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

NEWS

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,20 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? 2019, PHP 7.1.29
44

5+
- EXIF
6+
. Fixed bug #77950 (Heap-buffer-overflow in _estrndup via exif_process_IFD_TAG).
7+
(CVE-2019-11036) (Stas)
58

9+
- Mail
10+
. Fixed bug #77821 (Potential heap corruption in TSendMail()). (cmb)
611

712
04 Apr 2019, PHP 7.1.28
813

914
- EXIF:
10-
. Fixed bug #77753 (Heap-buffer-overflow in php_ifd_get32s). (Stas)
11-
. Fixed bug #77831 (Heap-buffer-overflow in exif_iif_add_value). (Stas)
15+
. Fixed bug #77753 (Heap-buffer-overflow in php_ifd_get32s). (CVE-2019-11034)
16+
(Stas)
17+
. Fixed bug #77831 (Heap-buffer-overflow in exif_iif_add_value).
18+
(CVE-2019-11035) (Stas)
1219

1320
- SQLite3:
1421
. Added sqlite3.defensive INI directive. (BohwaZ)

ext/exif/exif.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2891,7 +2891,7 @@ static int exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, cha
28912891
offset_base is ImageInfo->file.list[sn].data-dir_offset
28922892
dir_entry - offset_base is dir_offset+2+i*12
28932893
*/
2894-
if (byte_count > IFDlength || offset_val > IFDlength-byte_count || value_ptr < dir_entry || offset_val < (size_t)(dir_entry-offset_base)) {
2894+
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) {
28952895
/* It is important to check for IMAGE_FILETYPE_TIFF
28962896
* JPEG does not use absolute pointers instead its pointers are
28972897
* relative to the start of the TIFF header in APP1 section. */

ext/exif/tests/bug77950.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
Bug #77950 (Heap-buffer-overflow in _estrndup via exif_process_IFD_TAG)
3+
--SKIPIF--
4+
<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?>
5+
--FILE--
6+
<?php
7+
exif_read_data(__DIR__."/bug77950.tiff");
8+
?>
9+
DONE
10+
--EXPECTF--
11+
%A
12+
DONE

ext/exif/tests/bug77950.tiff

1.24 KB
Binary file not shown.

0 commit comments

Comments
 (0)