Bug #48465 [Csd->Asn]: sys_get_temp_dir() possibly inconsistent when using TMPDIR
| From: | pajoye@php.net | Date: | Mon, 28 Mar 2011 13:35:33 +0000 |
| Subject: | Bug #48465 [Csd->Asn]: sys_get_temp_dir() possibly inconsistent when using TMPDIR | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-159810@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=48465&edit=1
ID: 48465
Updated by: pajoye@php.net
Reported by: marcel dot esser at gmail dot com
Summary: sys_get_temp_dir() possibly inconsistent when using
TMPDIR
-Status: Closed
+Status: Assigned
Type: Bug
Package: Scripting Engine problem
Operating System: *
PHP Version: 5.*, 6CVS (2009-06-04)
-Assigned To:
+Assigned To: pajoye
Block user comment: N
Private report: N
New Comment:
Not fixed on windows
Previous Comments:
------------------------------------------------------------------------
[2009-06-24 12:21:54] iliaa@php.net
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
------------------------------------------------------------------------
[2009-06-04 11:57:05] jani@php.net
It's not MacOSX specific, you can always set TMPDIR whatever you want.
------------------------------------------------------------------------
[2009-06-04 06:23:14] marcel dot esser at gmail dot com
Alternative patch:
--- php52/php5/main/php_open_temporary_file.c 2009-06-03
13:42:44.000000000 -0400
+++ /Users/marcelesser/php_open_temporary_file.c 2009-06-04
02:19:29.000000000 -0400
@@ -200,9 +200,18 @@
{
char* s = getenv("TMPDIR");
if (s) {
- temporary_directory = strdup(s);
+ int last_char_idx = strlen(s) - 1;
+
+ /* on some systems (notably mac os x) TMPDIR has a
DIRECTORY_SEPARATOR appended */
+ if(s[last_char_idx] == DEFAULT_SLASH) {
+ temporary_directory = tsrm_strndup(s,last_char_idx);
+ } else {
+ temporary_directory = strdup(s);
+ }
+
return temporary_directory;
}
+
}
#ifdef P_tmpdir
/* Use the standard default temporary directory. */
------------------------------------------------------------------------
[2009-06-04 06:00:13] kalle@php.net
Instead of two strlen() call, i could see it being defined to a value.
Adding something like int len = strlen(s); after the if and before the
first strdup, however im not on OSX so i wont touch it :)
------------------------------------------------------------------------
[2009-06-03 17:53:46] marcel dot esser at gmail dot com
Pardon, I meant 5.2.9 CVS
Also, here is diff -u output:
--- main/php_open_temporary_file.c 2009-06-03 13:42:44.000000000 -0400
+++ /Users/marcelesser/php_open_temporary_file.c 2009-06-03
13:43:48.000000000 -0400
@@ -200,9 +200,16 @@
{
char* s = getenv("TMPDIR");
if (s) {
- temporary_directory = strdup(s);
+ /* on some systems (notably mac os x) TMPDIR has a
DIRECTORY_SEPARATOR appended */
+ if(s[strlen(s)-1] == DEFAULT_SLASH) {
+ temporary_directory = tsrm_strndup(s,strlen(s)-1);
+ } else {
+ temporary_directory = strdup(s);
+ }
+
return temporary_directory;
}
+
}
#ifdef P_tmpdir
/* Use the standard default temporary directory. */
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/bug.php?id=48465
--
Edit this bug report at http://bugs.php.net/bug.php?id=48465&edit=1