Bug #72278 [Opn->Ana]: getimagesize returning FALSE on valid jpg

From: Date: Fri, 27 May 2016 22:28:44 +0000
Subject: Bug #72278 [Opn->Ana]: getimagesize returning FALSE on valid jpg
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-201303@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72278&edit=1

 ID:                 72278
 Updated by:         requinix@php.net
 Reported by:        bfarber at invisiopower dot com
 Summary:            getimagesize returning FALSE on valid jpg
-Status:             Open
+Status:             Analyzed
 Type:               Bug
 Package:            GetImageSize related
 Operating System:   AWS / Windows
 PHP Version:        5.6.22
 Block user comment: N
 Private report:     N

 New Comment:

The image has some extra bytes in it that are messing up the detection, but there's not much
technical information about JPEGs out there and the standard itself is paywalled so I can't
verify if it's technically legal or just a vendor quirk. If I open the image in GIMP it warns
me about the extra bytes and recovers.

Those extra bytes are part of the 0xE1 Exif frame starting at offset 0x15. It says length
0x7D08/32008 but there are then 260 bytes of 0x00 unaccounted for until the next 0xFFED. Image
suggests it's from Photoshop CS2?

Could image.c's php_next_marker gracefully handle this situation? Automatically consume any
"leading" nulls it finds?


Previous Comments:
------------------------------------------------------------------------
[2016-05-27 20:45:31] bfarber at invisiopower dot com

Description:
------------
The documentation for getimagesize() indicates the function returns FALSE on failure, so the
function is behaving as described, however I cannot find any reason getimagesize() should be failing
to parse this particular image. A client has supplied a valid jpeg image and I can read the EXIF
data from it with a standalone parser, but getimagesize() fails to parse it.

We have tested on multiple versions and have seen the same behavior on all environments we've
tested on. I have not tested PHP7 yet. I have tested on Amazon's hosting environment, as well
as my local WAMP stack.

http://bfarber.com/getimagesize_test/test.php
Image can be found here: http://bfarber.com/getimagesize_test/image.jpg

Test script:
---------------
<?php

ini_set('display_errors',1);
error_reporting(E_ALL);

print "PHP version is " . PHP_VERSION . "<br>";
var_dump( getimagesize('image.jpg') );
exit;

Expected result:
----------------
I should see an array output with the image width, height, etc.

Actual result:
--------------
boolean false is returned


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=72278&edit=1


Thread (9 messages)

« previous php.bugs (#201303) next »