php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17528 imagecreatefromstring() enhancement suggestions
Submitted: 2002-05-30 10:30 UTC Modified: 2002-06-28 05:25 UTC
From: sonnysavage at yahoo dot com Assigned:
Status: Closed Package: GD related
PHP Version: 4.2.1 OS: Windows 98 (1st ed)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: sonnysavage at yahoo dot com
New email:
PHP Version: OS:

 

 [2002-05-30 10:30 UTC] sonnysavage at yahoo dot com
My machine is a Pentium 233MMX with 160 MB RAM.

I have tested this with:
 Apache 1.3.24 AND 2.0.36
 PHP 4.2.1 - php_gd.dll AND php_gd2.dll (only one at a time)

Here is the code being executed:
$query  = "SELECT image, width, height FROM site_image";
$query .= " WHERE image_id=\"".$image_id."\";";
$result = mysql_query($query, $linkid);
$rowarray = mysql_fetch_array($result, MYSQL_ASSOC);
$old_image = imagecreatefromstring($rowarray["image"]);

I know that it is the imagecreatefromstring() function causing the crash because when I remove it, the code doesn't work, but it doesn't crash either.

I get the error:
"This program has performed and illegal operation and will be shut down."

These are the details:
APACHE caused an invalid page fault in
module PHP_GD2.DLL at 0197:017c1317.
Registers:
EAX=05095000 CS=0197 EIP=017c1317 EFLGS=00010246
EBX=00000000 SS=019f ESP=0195f7e8 EBP=0195f7f8
ECX=00000000 DS=019f ESI=007a6b50 FS=8b27
EDX=ffffe2ee ES=019f EDI=00000001 GS=0000
Bytes at CS:EIP:
8a 08 89 4d fc 8b 55 f0 83 c2 01 89 55 f0 33 c0 
Stack dump:
05095000 ffffe2ee 006d78d0 00000000 0195f808 017c1dc9 0195f93c 000000da 0195f820 017d2b05 0195f93c 017d2f44 006d78b8 006d78d0 0195f834 017c05c6 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-30 18:09 UTC] mfischer@php.net
Please provide a small, self-contained example (read: not database dependency) which reproduces the problem.
 [2002-05-30 21:45 UTC] sonnysavage at yahoo dot com
On trying to fulfill your request for a self-contained example, I discovered that I wasn't getting the entire image into the database (fopen() on Win32).  I think that the imagecreatefromstring() function should be able to more robustly handle input.

Now I have a different problem. The data string I am retrieving is a JPEG.  The error message I get is:
Warning: imagecreatefromstring: Passed data is not in 'WBMP' format in c:\www\mcsda\includes\class.image.php on line 16
Warning: Couldn't create GD Image Stream out of Data in c:\www\mcsda\includes\class.image.php on line 16

I know that my string is not in WBMP format.  Is that the only format this function can take as input?
 [2002-06-01 20:39 UTC] sonnysavage at yahoo dot com
After more searching, I discovered that the variable name had been mistyped.  I had been passing the function an empty string.  My code is working correctly now.

Based on my experience, I'd like to suggest the following enhancements:
1.  The function should be more robust and not crash the web server when it gets bad data.
2.  When data is not an image at all (i.e. and empty string), the error message should reflect that.
 -> Passed data was null
 -> Passed data was not a valid image
 [2002-06-28 05:25 UTC] sniper@php.net
This bug has been fixed in CVS. You can grab a snapshot of the
CVS version at http://snaps.php.net/. In case this was a documentation 
problem, the fix will show up soon at http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites.
Thank you for the report, and for helping us make PHP better.


I fixed the crash bug.
 [2010-05-24 01:44 UTC] pajoye@php.net
Automatic comment from SVN on behalf of pajoye
Revision: http://svn.php.net/viewvc/?view=revision&revision=299674
Log: - #17528, direct link to create a new bug
 [2010-05-24 01:44 UTC] pajoye@php.net
Automatic comment from SVN on behalf of pajoye
Revision: http://svn.php.net/viewvc/?view=revision&revision=299675
Log: - #17528, direct link to create a new bug
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 23:01:29 2024 UTC