From: Ilia Alshanetsky Date: Wed, 24 Jun 2009 12:21:37 +0000 (+0000) Subject: MFB: Fixed bug #48465 (sys_get_temp_dir() possibly inconsistent when using X-Git-Tag: php-5.4.0alpha1~191^2~3246 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d71956b183c80691e777e029e77335f7f946c259;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 20279a7d2f..232e0aabf9 100644 --- a/main/php_open_temporary_file.c +++ b/main/php_open_temporary_file.c @@ -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; } }