Bug #77195 [Asn->Csd]: Incorrect error handling of imagecreatefromjpeg function with corrupt jpeg

From: Date: Sat, 24 Nov 2018 12:02:12 +0000
Subject: Bug #77195 [Asn->Csd]: Incorrect error handling of imagecreatefromjpeg function with corrupt jpeg
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-218121@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77195&edit=1 ID: 77195 Updated by: cmb@php.net Reported by: peehaa@php.net Summary: Incorrect error handling of imagecreatefromjpeg function with corrupt jpeg -Status: Assigned +Status: Closed Type: Bug Package: GD related Operating System: Windows PHP Version: Irrelevant Assigned To: cmb Block user comment: N Private report: N New Comment: Automatic comment on behalf of cmbecker69@gmx.de Revision: http://git.php.net/?p=php-src.git;a=commit;h=60a9f7a3a3502bfb7118f7fc5c06f9fdf713efad Log: Fix #77195: Incorrect error handling of imagecreatefromjpeg() Previous Comments: ------------------------------------------------------------------------ [2018-11-23 23:16:28] cmb@php.net > Also note I am using the bundled gd lib Ah, then the other ticket is certainly unrelated. ------------------------------------------------------------------------ [2018-11-23 20:10:33] peehaa@php.net Also note I am using the bundled gd lib ------------------------------------------------------------------------ [2018-11-23 20:00:01] peehaa@php.net How is this a dupe? I am getting unexpected output (even when using the STFU operator). The dupe is about getting an unexpected fatal error. Am I missing something here? ------------------------------------------------------------------------ [2018-11-23 17:42:33] cmb@php.net This looks like a duplicate of bug #75888. ------------------------------------------------------------------------ [2018-11-23 15:11:53] peehaa@php.net 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 this bug report at https://bugs.php.net/bug.php?id=77195&edit=1

« previous php.bugs (#218121) next »