Fix bug #65873 - Integer overflow in exif_read_data()

This commit is contained in:
Stanislav Malyshev 2013-12-08 15:37:35 -08:00
parent 68a73ce3c4
commit cbcf6e1880
2 changed files with 9 additions and 1 deletions

3
NEWS
View file

@ -17,6 +17,9 @@ PHP NEWS
. Fixed bug #65196 (Passing DOMDocumentFragment to DOMDocument::saveHTML()
Produces invalid Markup). (Mike)
- Exif:
. Fixed bug #65873 (Integer overflow in exif_read_data()). (Stas)
- Filter:
. Fixed bug #66229 (128.0.0.0/16 isn't reserved any longer). (Adam)

View file

@ -2852,7 +2852,12 @@ static int exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, cha
offset_val = php_ifd_get32u(dir_entry+8, ImageInfo->motorola_intel);
/* If its bigger than 4 bytes, the dir entry contains an offset. */
value_ptr = offset_base+offset_val;
if (byte_count > IFDlength || offset_val > IFDlength-byte_count || value_ptr < dir_entry) {
/*
dir_entry is ImageInfo->file.list[sn].data+2+i*12
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)) {
/* 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. */