From: marcel dot esser at gmail dot com
Operating system: Mac OS X, possibly others
PHP version: 5.2.9
PHP Bug Type: Directory function related
Bug description: sys_get_temp_dir() possibly inconsistent when using TMPDIR
Description:
------------
Some systems add a terminating directory separator to the TMPDIR env
variable, such as Mac OS X. This is not consistent with the fallback
default for sys_get_temp_dir(), which is '/tmp'. This causes problems when
constructing filenames when not using tempnam().
Here is a short patch against 5.2 HEAD
203c203,209
< 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);
> }
>
205a212
>
Reproduce code:
---------------
<?php
echo sys_get_temp_dir() . "\n";
Expected result:
----------------
/var/folders/yC/yCto0tGnHIqmgIv2v8-pEk+++TI/-Tmp-
Actual result:
--------------
/var/folders/yC/yCto0tGnHIqmgIv2v8-pEk+++TI/-Tmp-/
--
Edit bug report at http://bugs.php.net/?id=48465&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=48465&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=48465&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=48465&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=48465&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=48465&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=48465&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=48465&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=48465&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=48465&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=48465&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=48465&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=48465&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=48465&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=48465&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48465&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=48465&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=48465&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=48465&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=48465&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=48465&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=48465&r=mysqlcfg