Bug #75275 [Opn->Fbk]: imagecreatefrom Functions Not Failing On Corrupt Images

From: Date: Thu, 28 Sep 2017 14:51:33 +0000
Subject: Bug #75275 [Opn->Fbk]: imagecreatefrom Functions Not Failing On Corrupt Images
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-211420@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75275&edit=1 ID: 75275 Updated by: requinix@php.net Reported by: coryldean at gmail dot com Summary: imagecreatefrom Functions Not Failing On Corrupt Images -Status: Open +Status: Feedback Type: Bug Package: GD related Operating System: Linux PHP Version: 7.1.9 Block user comment: N Private report: N New Comment: Can you provide a copy of the corrupt image? Previous Comments: ------------------------------------------------------------------------ [2017-09-28 14:45:24] coryldean at gmail dot com 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 this bug report at https://bugs.php.net/bug.php?id=75275&edit=1

« previous php.bugs (#211420) next »