Skip to content

Commit bc88223

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fix bug #77950 - Heap-buffer-overflow in _estrndup via exif_process_IFD_TAG
2 parents 97c7281 + db0de95 commit bc88223

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

ext/exif/exif.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3217,7 +3217,7 @@ static int exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, cha
32173217
offset_base is ImageInfo->file.list[sn].data-dir_offset
32183218
dir_entry - offset_base is dir_offset+2+i*12
32193219
*/
3220-
if (byte_count > IFDlength || offset_val > IFDlength-byte_count || value_ptr < dir_entry || offset_val < (size_t)(dir_entry-offset_base)) {
3220+
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) {
32213221
/* It is important to check for IMAGE_FILETYPE_TIFF
32223222
* JPEG does not use absolute pointers instead its pointers are
32233223
* 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)