]> granicus.if.org Git - php/commitdiff
Fixed bug #48465 (sys_get_temp_dir() possibly inconsistent when using
authorIlia Alshanetsky <iliaa@php.net>
Wed, 24 Jun 2009 12:21:20 +0000 (12:21 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Wed, 24 Jun 2009 12:21:20 +0000 (12:21 +0000)
TMPDIR).

NEWS
main/php_open_temporary_file.c

diff --git a/NEWS b/NEWS
index 39d9baf58b1a667f88739a6c510cc7efa96d2d3b..eed220fa757cde7950fcd8534632246a8500295c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,8 @@
 - Fixed bug #48619 (imap_search ALL segfaults). (Pierre)
 - Fixed bug #48555 (ImageFTBBox() differs from previous versions for texts
   with new lines) (Takeshi Abe)
+- Fixed bug #48465 (sys_get_temp_dir() possibly inconsistent when using
+  TMPDIR). (Ilia)
 - Fixed bug #48450 (Compile failure under IRIX 6.5.30 building gd.c). (Kalle)
 - Fixed bug #48276 (date("Y") on big endian machines produces the
   wrong result). (Scott)
index ee7f0df75f3668db954a405c00a2bafed4b18cb0..af86a0b6909e8f9745bce9cc9b4b62ba3b4e6b45 100644 (file)
@@ -200,7 +200,14 @@ PHPAPI const char* php_get_temporary_directory(void)
        {
                char* s = getenv("TMPDIR");
                if (s) {
-                       temporary_directory = strdup(s);
+                       int len = strlen(s);
+
+                       if (s[len - 1] == DEFAULT_SLASH) {
+                               temporary_directory = zend_strndup(s, len - 1);
+                       } else {
+                               temporary_directory = zend_strndup(s, len);
+                       }
+
                        return temporary_directory;
                }
        }