Skip to content

Commit de4a2c3

Browse files
committed
Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5: Fix bug #65873 - Integer overflow in exif_read_data()
2 parents 85a1016 + 57408f9 commit de4a2c3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

ext/exif/exif.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2842,7 +2842,12 @@ static int exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, cha
28422842
offset_val = php_ifd_get32u(dir_entry+8, ImageInfo->motorola_intel);
28432843
/* If its bigger than 4 bytes, the dir entry contains an offset. */
28442844
value_ptr = offset_base+offset_val;
2845-
if (byte_count > IFDlength || offset_val > IFDlength-byte_count || value_ptr < dir_entry) {
2845+
/*
2846+
dir_entry is ImageInfo->file.list[sn].data+2+i*12
2847+
offset_base is ImageInfo->file.list[sn].data-dir_offset
2848+
dir_entry - offset_base is dir_offset+2+i*12
2849+
*/
2850+
if (byte_count > IFDlength || offset_val > IFDlength-byte_count || value_ptr < dir_entry || offset_val < (size_t)(dir_entry-offset_base)) {
28462851
/* It is important to check for IMAGE_FILETYPE_TIFF
28472852
* JPEG does not use absolute pointers instead its pointers are
28482853
* relative to the start of the TIFF header in APP1 section. */

0 commit comments

Comments
 (0)