Bug #69706 [Opn->Fbk]: getimagesize() can fail if the underlying stream doensn't support seeking

From: Date: Thu, 02 Apr 2020 11:25:32 +0000
Subject: Bug #69706 [Opn->Fbk]: getimagesize() can fail if the underlying stream doensn't support seeking
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-226410@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69706&edit=1 ID: 69706 Updated by: cmb@php.net Reported by: deviantintegral at gmail dot com Summary: getimagesize() can fail if the underlying stream doensn't support seeking -Status: Open +Status: Feedback Type: Bug Package: GetImageSize related Operating System: Any PHP Version: 5.6.9 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: For SEEK_CUR and positive offsets, non-seekable streams are supposed to be read (discarding what was written). So if you can still reproduce this issue with any of the actively supported PHP versions[1], please provide a minimal self-contained reproduce script. [1] <https://www.php.net/supported-versions.php> Previous Comments: ------------------------------------------------------------------------ [2015-05-25 18:29:08] deviantintegral at gmail dot com Description: ------------ I've verified this is an issue on PHP 5.4, 5.6, and statically on the master branch. The AWS SDK (https://aws.amazon.com/sdk-for-php/) 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. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=69706&edit=1

« previous php.bugs (#226410) next »