Bug #75778 [Opn->Nab]: Corrupt PNG image causes non-recoverable fatal PHP error

From: Date: Mon, 08 Jan 2018 13:47:40 +0000
Subject: Bug #75778 [Opn->Nab]: Corrupt PNG image causes non-recoverable fatal PHP error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-213425@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75778&edit=1 ID: 75778 Updated by: cmb@php.net Reported by: info at e-abi dot ee Summary: Corrupt PNG image causes non-recoverable fatal PHP error -Status: Open +Status: Not a bug Type: Bug Package: GD related Operating System: Debian GNU/Linux 9 (stretch) PHP Version: 5.6.33 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: > [GD Version] => 2.2.4 Actually, this is not a PHP bug, but a problem of GD which has been fixed as of GD 2.2.5, see <https://github.com/libgd/libgd/issues/338>. Previous Comments: ------------------------------------------------------------------------ [2018-01-08 12:00:35] info at e-abi dot ee Description: ------------ Corrupt PNG image causes non-recoverable fatal PHP error. PHP Fatal error: imagecreatefrompng(): gd-png: fatal libpng error: Read Error Also affected: PHP 7.0.26 PHP 7.1.13 PHP 7.2.1 Test script: --------------- <?php ini_set('display_errors', 1); #actual image location: http://www.knoraki.se/media/ACME_191101_440x440_1.png echo print_r(gd_info(), true); $image = false; $filename = 'ACME_191101_440x440_1.png'; $image = imagecreatefrompng($filename); //$image = getimagesize($filename); if (!$image) { $image = 'failed'; } echo print_r($image, true); Expected result: ---------------- Array ( [GD Version] => bundled (2.1.0 compatible) [FreeType Support] => 1 [FreeType Linkage] => with freetype [T1Lib Support] => [GIF Read Support] => 1 [GIF Create Support] => 1 [JPEG Support] => 1 [PNG Support] => 1 [WBMP Support] => 1 [XPM Support] => 1 [XBM Support] => 1 [WebP Support] => 1 [JIS-mapped Japanese Font Support] => ) Warning: imagecreatefrompng(): gd-png: fatal libpng error: Read Error: truncate d data in D:\Bill-Data\tmp\php-gd-bug\image-test.php on line 8 Warning: imagecreatefrompng(): gd-png error: setjmp returns error condition in D :\Bill-Data\tmp\php-gd-bug\image-test.php on line 8 Warning: imagecreatefrompng(): 'ACME_191101_440x440_1.png' is not a valid PNG fi le in D:\Bill-Data\tmp\php-gd-bug\image-test.php on line 8 failed Actual result: -------------- root@vmi137424:/var/www/magento.eabi.ee/php-gd-bug# php7.1 image-test.php Array ( [GD Version] => 2.2.4 [FreeType Support] => 1 [FreeType Linkage] => with freetype [GIF Read Support] => 1 [GIF Create Support] => 1 [JPEG Support] => 1 [PNG Support] => 1 [WBMP Support] => 1 [XPM Support] => 1 [XBM Support] => 1 [WebP Support] => 1 [JIS-mapped Japanese Font Support] => ) PHP Fatal error: imagecreatefrompng(): gd-png: fatal libpng error: Read Error: truncated data in /var/www/magento.eabi.ee/php-gd-bug/image-test.php on line 8 Fatal error: imagecreatefrompng(): gd-png: fatal libpng error: Read Error: truncated data in /var/www/magento.eabi.ee/php-gd-bug/image-test.php on line 8 #notice how the final "failed" statement is not displayed because the script is halted. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=75778&edit=1

« previous php.bugs (#213425) next »