Bug #75708 [Opn->Ver]: getimagesize with "&$imageinfo" fails on StreamWrappers

From: Date: Wed, 20 Dec 2017 16:18:58 +0000
Subject: Bug #75708 [Opn->Ver]: getimagesize with "&$imageinfo" fails on StreamWrappers
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-213181@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75708&edit=1

 ID:                 75708
 Updated by:         cmb@php.net
 Reported by:        joehoyle at gmail dot com
 Summary:            getimagesize with "&$imageinfo" fails on
                     StreamWrappers
-Status:             Open
+Status:             Verified
 Type:               Bug
 Package:            Streams related
 Operating System:   Alpine Linux
 PHP Version:        7.1.12
 Block user comment: N
 Private report:     N

 New Comment:

I can confirm the erroneous behavior.  Interestingly, calling
getimagesize() without the second parameter succeeds without
warnings.  The only relevant difference is that the info parameter
causes php_read_APP() to be called, while without info parameter
php_skip_variable() is called[1].  However, the relevant
difference between php_skip_variable()[2] and php_read_APP()[3] is
that the former calls php_stream_seek() while the latter calls
php_stream_read() (both with the same offset/length).  Apparently,
there is an issue regarding php_stream_read(); possibly related to
bug #72561.

[1] <https://github.com/php/php-src/blob/PHP-7.2.0/ext/standard/image.c#L535-L543>
[2] <https://github.com/php/php-src/blob/PHP-7.2.0/ext/standard/image.c#L424-L437>
[3] <https://github.com/php/php-src/blob/PHP-7.2.0/ext/standard/image.c#L439-L471>


Previous Comments:
------------------------------------------------------------------------
[2017-12-20 02:54:34] joehoyle at gmail dot com

Description:
------------
When using getimagesize( $path, $imageinfo ) on specific images in conjunction with a custom
StreamWrapper path, multiple "PHP Warning:  getimagesize(): corrupt JPEG data: 536 extraneous
bytes before marker in..." errors are shown, and the $imageinfo is empty.

This also happens with a "fake filesystem streamwrapper" as demonstrated.

Test script:
---------------
https://gist.github.com/joehoyle/b9484e6375ce3a1d4cbefe5e439ef80d

Using image: https://joehoyle-captured.s3.amazonaws.com/test.jpg

Expected result:
----------------
bool(true)
bool(true)
[20-Dec-2017 02:51:20 UTC] PHP Warning:  getimagesize(): corrupt JPEG data: 183 extraneous bytes
before marker in /usr/src/app/test.php on line 60
[20-Dec-2017 02:51:20 UTC] PHP Warning:  getimagesize(): corrupt JPEG data: 140 extraneous bytes
before marker in /usr/src/app/test.php on line 60
[20-Dec-2017 02:51:20 UTC] PHP Warning:  getimagesize(): corrupt JPEG data: 175 extraneous bytes
before marker in /usr/src/app/test.php on line 60
[20-Dec-2017 02:51:20 UTC] PHP Warning:  getimagesize(): corrupt JPEG data: 854 extraneous bytes
before marker in /usr/src/app/test.php on line 60
[20-Dec-2017 02:51:20 UTC] PHP Warning:  getimagesize(): corrupt JPEG data: 723 extraneous bytes
before marker in /usr/src/app/test.php on line 60
[20-Dec-2017 02:51:20 UTC] PHP Warning:  getimagesize(): corrupt JPEG data: 31 extraneous bytes
before marker in /usr/src/app/test.php on line 60
[20-Dec-2017 02:51:20 UTC] PHP Warning:  getimagesize(): corrupt JPEG data: 79 extraneous bytes
before marker in /usr/src/app/test.php on line 60
[20-Dec-2017 02:51:20 UTC] PHP Warning:  getimagesize(): corrupt JPEG data: 502 extraneous bytes
before marker in /usr/src/app/test.php on line 60
[20-Dec-2017 02:51:20 UTC] PHP Warning:  getimagesize(): corrupt JPEG data: 48 extraneous bytes
before marker in /usr/src/app/test.php on line 60
[20-Dec-2017 02:51:20 UTC] PHP Warning:  getimagesize(): corrupt JPEG data: 116 extraneous bytes
before marker in /usr/src/app/test.php on line 60
[20-Dec-2017 02:51:20 UTC] PHP Warning:  getimagesize(): corrupt JPEG data: 295 extraneous bytes
before marker in /usr/src/app/test.php on line 60
[20-Dec-2017 02:51:20 UTC] PHP Warning:  getimagesize(): corrupt JPEG data: 710 extraneous bytes
before marker in /usr/src/app/test.php on line 60
[20-Dec-2017 02:51:20 UTC] PHP Warning:  getimagesize(): corrupt JPEG data: 536 extraneous bytes
before marker in /usr/src/app/test.php on line 60
done

Actual result:
--------------
bool(true)
bool(true)
done


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



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


Thread (7 messages)

« previous php.bugs (#213181) next »