From: Ilia Alshanetsky Date: Tue, 30 Jun 2009 12:20:35 +0000 (+0000) Subject: MFB: Fixed bug #48465 (sys_get_temp_dir() possibly inconsistent when using X-Git-Tag: php-5.3.1RC1~492 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ae2c5ee7d49afaf0c6ede990ff162d496c7890e4;p=php MFB: Fixed bug #48465 (sys_get_temp_dir() possibly inconsistent when using TMPDIR). --- diff --git a/main/php_open_temporary_file.c b/main/php_open_temporary_file.c index ee7f0df75f..7c90f1f39b 100644 --- a/main/php_open_temporary_file.c +++ b/main/php_open_temporary_file.c @@ -199,8 +199,15 @@ PHPAPI const char* php_get_temporary_directory(void) /* On Unix use the (usual) TMPDIR environment variable. */ { char* s = getenv("TMPDIR"); - if (s) { - temporary_directory = strdup(s); + if (s && *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; } }