Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 115670 - The PHP functions imagepng() and imagejpeg() fail to create non-existing files
Summary: The PHP functions imagepng() and imagejpeg() fail to create non-existing files
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High major (vote)
Assignee: PHP Bugs
URL: http://bugs.php.net/bug.php?id=35246
Whiteboard:
Keywords: Inclusion
Depends on:
Blocks:
 
Reported: 2005-12-15 09:16 UTC by Kai Blaschke
Modified: 2006-01-04 03:40 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch containing CVS fixes in PHP 4.4.2 to fix the described problem (php4.4.1-gdlib_file_creation.patch,4.34 KB, patch)
2005-12-15 09:20 UTC, Kai Blaschke
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kai Blaschke 2005-12-15 09:16:45 UTC
In PHP 4.4.x, the GD functions imagepng() and imagejpeg() fail to create new
files , even if the folder permissions are correctly set. If the file is created
with 'touch' beforehand, the function will succeed and write the image data to
the file. The error is associated with the open_basedir restriction, and does
only occur if it is turned on.

Reproducible: Always
Steps to Reproduce:
1. Create a PHP file "test.php" containing just these lines:
<?php
$img = imagecreate(10,10);
$col = imagecolorallocate($img,0,0,0);
imagepng($img, "test.png");
?>

2. Make sure the folder permissions are set correctly.
3. Open the script in a browser.
Actual Results:  
You will encounter the following error:

Warning: imagepng(): Unable to access test.png in
/folder/to/test.php on line 4
Warning: imagepng(): Invalid filename 'test.png' in
/folder/to/test.php on line 4

The image file will not be created.

Expected Results:  
The image file should be created without any error message.

This does only affect the Apache SAPI of PHP with open_basedir set.
Comment 1 Kai Blaschke 2005-12-15 09:20:28 UTC
Created attachment 74810 [details, diff]
Patch containing CVS fixes in PHP 4.4.2 to fix the described problem

This patch fixes the addressed issue by adding a new macro to check the
open_basedir restrictions. The patch is actually a diff between the current
4.4.1 release and the latest stable CVS snapshot.
Comment 2 Kai Blaschke 2005-12-16 12:02:20 UTC
After additional testing, I must correct that this bug is dependent on the safe_mode flag, which must be turned on in order to reproduce the described behaviour. open_basedir does not affect this bug, if the paths and permissions are set correctly.
Comment 3 Luca Longinotti (RETIRED) gentoo-dev 2006-01-04 03:40:45 UTC
The patch you attached is part of the updates the new dev-lang/php-4.4.1-r3 includes, so this then should fix your GD safe_mode/open_basedir issues, try that and reopen if it doesn't work.
Best regards, CHTEKK.