Skip to content

Commit cbcf6e1

Browse files
committed
Fix bug #65873 - Integer overflow in exif_read_data()
1 parent 68a73ce commit cbcf6e1

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ PHP NEWS
1717
. Fixed bug #65196 (Passing DOMDocumentFragment to DOMDocument::saveHTML()
1818
Produces invalid Markup). (Mike)
1919

20+
- Exif:
21+
. Fixed bug #65873 (Integer overflow in exif_read_data()). (Stas)
22+
2023
- Filter:
2124
. Fixed bug #66229 (128.0.0.0/16 isn't reserved any longer). (Adam)
2225

ext/exif/exif.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2852,7 +2852,12 @@ static int exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, cha
28522852
offset_val = php_ifd_get32u(dir_entry+8, ImageInfo->motorola_intel);
28532853
/* If its bigger than 4 bytes, the dir entry contains an offset. */
28542854
value_ptr = offset_base+offset_val;
2855-
if (byte_count > IFDlength || offset_val > IFDlength-byte_count || value_ptr < dir_entry) {
2855+
/*
2856+
dir_entry is ImageInfo->file.list[sn].data+2+i*12
2857+
offset_base is ImageInfo->file.list[sn].data-dir_offset
2858+
dir_entry - offset_base is dir_offset+2+i*12
2859+
*/
2860+
if (byte_count > IFDlength || offset_val > IFDlength-byte_count || value_ptr < dir_entry || offset_val < (size_t)(dir_entry-offset_base)) {
28562861
/* It is important to check for IMAGE_FILETYPE_TIFF
28572862
* JPEG does not use absolute pointers instead its pointers are
28582863
* relative to the start of the TIFF header in APP1 section. */

0 commit comments

Comments
 (0)