Bug #77195 [NEW]: Incorrect error handling of imagecreatefromjpeg function with corrupt jpeg

From: Date: Fri, 23 Nov 2018 15:11:53 +0000
Subject: Bug #77195 [NEW]: Incorrect error handling of imagecreatefromjpeg function with corrupt jpeg
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-218107@lists.php.net to get a copy of this message
From: peehaa Operating system: Windows PHP version: Irrelevant Package: GD related Bug Type: Bug Bug description:Incorrect error handling of imagecreatefromjpeg function with corrupt jpeg Description: ------------ The imagecreatefromjpeg function improperly handles errors when passing a corrupt jpeg image. Not only does it still output an error (coming from gd directly I guess), but it also spits out 3 PHP errors (1 notice and 2 warnings). Test script: --------------- Test image can be found at https://pieterhordijk.com/broken-mspaint.jpeg @imagecreatefromjpeg('/path/to/broken-mspaint.jpeg'); imagecreatefromjpeg('/path/to/broken-mspaint.jpeg'); Expected result: ---------------- First call with the STFU operator should output nothing. Second call without the STFU operators should probably just give one single php error instead of 3 Actual result: -------------- First call with the STFU operator: JPEG datastream contains no image Second call without the STFU operator: PHP Notice: imagecreatefromjpeg(): gd-jpeg, libjpeg: recoverable error: Corrupt JPEG data: 947 extraneous bytes before marker 0xd9 in /path/to/test.php on line 5 PHP Warning: imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error: in /path/to/test.php on line 5 JPEG datastream contains no image PHP Warning: imagecreatefromjpeg(): '/path/to/image/broken-mspaint.jpeg' is not a valid JPEG file in /path/to/test.php on line 5 -- Edit bug report at https://bugs.php.net/bug.php?id=77195&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77195&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77195&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77195&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=77195&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=77195&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=77195&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=77195&r=needscript Try newer version: https://bugs.php.net/fix.php?id=77195&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=77195&r=support Expected behavior: https://bugs.php.net/fix.php?id=77195&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=77195&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=77195&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=77195&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77195&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=77195&r=dst IIS Stability: https://bugs.php.net/fix.php?id=77195&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=77195&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=77195&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=77195&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=77195&r=mysqlcfg

« previous php.bugs (#218107) next »