Bug #75778 [NEW]: Corrupt PNG image causes non-recoverable fatal PHP error
| From: | info at e-abi dot ee | Date: | Mon, 08 Jan 2018 12:00:38 +0000 |
| Subject: | Bug #75778 [NEW]: Corrupt PNG image causes non-recoverable fatal PHP error | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-213424@lists.php.net to get a copy of this message | ||
From: info at e-abi dot ee
Operating system: Debian GNU/Linux 9 (stretch)
PHP version: 5.6.33
Package: GD related
Bug Type: Bug
Bug description:Corrupt PNG image causes non-recoverable fatal PHP error
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 bug report at https://bugs.php.net/bug.php?id=75778&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75778&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75778&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75778&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=75778&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=75778&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=75778&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=75778&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=75778&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=75778&r=support
Expected behavior: https://bugs.php.net/fix.php?id=75778&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=75778&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=75778&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=75778&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75778&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=75778&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=75778&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=75778&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75778&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=75778&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=75778&r=mysqlcfg