|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73479 Invalid string passed into imagecreatefromstring causes fatal error
Submitted: 2016-11-08 17:28 UTC Modified: 2017-08-30 12:09 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: dougnelson at silktide dot com Assigned: cmb (profile)
Status: Closed Package: GD related
PHP Version: 7.0.12 OS: Ubuntu 14.04
Private report: No CVE-ID: None
 [2016-11-08 17:28 UTC] dougnelson at silktide dot com
GD Support => enabled
GD Version => bundled (2.1.0 compatible)

Running the below test code that attempts to create a JPG using imagecreatefromstring will cause a E_WARNING, but not a fatal error.

GD Support => enabled
GD headers Version => 2.2.3
GD library Version => 2.2.3

To run the same test code cases a fatal exception that is unable to be caught.

Test script:

Expected result:
An E_WARNING warning of the same.

Actual result:
PHP Fatal error:  imagecreatefromstring(): gd-jpeg: JPEG library reports unrecoverable error: Invalid JPEG file structure: SOS before SOF in /tmp/foo.php on line 7


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-11-09 17:00 UTC]
-Status: Open +Status: Analyzed -Assigned To: +Assigned To: cmb
 [2016-11-09 17:00 UTC]
I can confirm this issue.

It seems to me that should be addressed in libgd[1],
where libgd raises a GD_ERROR in case an "unrecoverable" error is
detected, but nonetheless is able to resume; note that if libgd can't
resume, also a GD_ERROR is raised, but exit() is called immediately

[1] <>
 [2016-11-09 17:09 UTC]
-Status: Analyzed +Status: Suspended
 [2016-11-09 17:09 UTC]
I've filed a respective ticket:
<>. Let's wait how this will be
 [2017-08-16 16:30 UTC]
-Assigned To: cmb +Assigned To:
 [2017-08-30 12:09 UTC]
-Status: Suspended +Status: Closed -Assigned To: +Assigned To: cmb
 [2017-08-30 12:09 UTC]
This issue is supposed to be solved by libgd 2.2.5 which just has
been released. Therefore I'm closing this ticket.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jun 13 23:01:32 2024 UTC