Bug #75275 [NEW]: imagecreatefrom Functions Not Failing On Corrupt Images
| From: | coryldean at gmail dot com | Date: | Thu, 28 Sep 2017 14:45:29 +0000 |
| Subject: | Bug #75275 [NEW]: imagecreatefrom Functions Not Failing On Corrupt Images | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-211419@lists.php.net to get a copy of this message | ||
From: coryldean at gmail dot com
Operating system: Linux
PHP version: 7.1.9
Package: GD related
Bug Type: Bug
Bug description:imagecreatefrom Functions Not Failing On Corrupt Images
Description:
------------
---
From manual page: http://www.php.net/function.imagecreatefromjpeg
---
When running the Test Script on PHP 5.2.17 it return false - as it
should - when trying to load a corrupt image. However, on PHP 7.1.9 the
Test Script returns a resource as if the image is fine.
Test script:
---------------
if(!imagecreatefromjpeg($FileSplFileInfo->getRealPath()))
{
echo 'ERROR - Corrupt Image';
}
else
{
echo 'SHOULD NOT GET HERE!';
}
Expected result:
----------------
When passing in a valid path to a corrupt .JPEG file, it should echo the
error message.
Below is what I get when running the script in PHP 5.2.17
Warning: imagecreatefromjpeg(): gd-jpeg, libjpeg: recoverable error:
Premature end of JPEG file
in PATH_TO_PHP_FILE_THAT_EXECUTED_CODE on line 491
Warning: imagecreatefromjpeg(): 'PATH_TO_FILE.JPEG' is not a valid JPEG
file in PATH_TO_PHP_FILE_THAT_EXECUTED_CODE on line 491
ERROR - Corrupt Image
Actual result:
--------------
Below is what I get when running the script in PHP 7.1.9
SHOULD NOT GET HERE!
--
Edit bug report at https://bugs.php.net/bug.php?id=75275&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75275&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75275&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75275&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=75275&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=75275&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=75275&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=75275&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=75275&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=75275&r=support
Expected behavior: https://bugs.php.net/fix.php?id=75275&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=75275&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=75275&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=75275&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75275&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=75275&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=75275&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=75275&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75275&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=75275&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=75275&r=mysqlcfg