|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69706 getimagesize() can fail if the underlying stream doensn't support seeking
Submitted: 2015-05-25 18:29 UTC Modified: -
Avg. Score:4.3 ± 0.9
Reproduced:8 of 8 (100.0%)
Same Version:4 (50.0%)
Same OS:2 (25.0%)
From: deviantintegral at gmail dot com Assigned:
Status: Open Package: GetImageSize related
PHP Version: 5.6.9 OS: Any
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
28 + 24 = ?
Subscribe to this entry?

 [2015-05-25 18:29 UTC] deviantintegral at gmail dot com
I've verified this is an issue on PHP 5.4, 5.6, and statically on the master branch.

The AWS SDK ( includes a stream wrapper that by default does not support seeking on files backed by S3. Calling getimagesize() on an image can fail if php_skip_variable() is called. I've seen this happen with images that specify the "Image Quality" EXIF tag, which is the M_APP15 constant in ext/standard/image.c.

The stream documentation states that seeking is not required to be supported by stream wrappers, and it's not clear that getimagesize() needs seeking to work properly.

I see two ways to improve this:

* Log a notice if php_skip_variable() tries to seek on an unseekable stream. That would have saved me a ton of time tracing this with GDB.
* Or, if a stream is not seekable, copy the file to the temporary file system and fetch metadata from there. 


Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Mar 29 10:01:24 2020 UTC