Skip to content

Commit c0aa23f

Browse files
committed
MFB: Fixed bug #48465 (sys_get_temp_dir() possibly inconsistent when using TMPDIR).
1 parent b8f295a commit c0aa23f

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

main/php_open_temporary_file.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,14 @@ PHPAPI const char* php_get_temporary_directory(void)
200200
{
201201
char* s = getenv("TMPDIR");
202202
if (s) {
203-
temporary_directory = strdup(s);
203+
int len = strlen(s);
204+
205+
if (s[len - 1] == DEFAULT_SLASH) {
206+
temporary_directory = zend_strndup(s, len - 1);
207+
} else {
208+
temporary_directory = zend_strndup(s, len);
209+
}
210+
204211
return temporary_directory;
205212
}
206213
}

0 commit comments

Comments
 (0)