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

main/php_open_temporary_file.c

index 20279a7d2ffe28e9ed8b45c8ec19a6a76c6fc106..232e0aabf9cd47786d3d3b23b6f2c32547191e47 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;
                }
        }