From 45b278cc34e7060c24c5529b51cc322df6844210 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Tue, 23 May 2006 23:22:16 +0000 Subject: [PATCH] MFB: Fixed handling of extremely long paths inside tempnam() function. --- main/php_open_temporary_file.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/main/php_open_temporary_file.c b/main/php_open_temporary_file.c index 66453581fb..b2e27e2f79 100644 --- a/main/php_open_temporary_file.c +++ b/main/php_open_temporary_file.c @@ -114,17 +114,16 @@ static int php_do_open_temporary_file(const char *path, const char *pfx, char ** path_len = strlen(path); - if (!(opened_path = emalloc(MAXPATHLEN))) { - return -1; - } - if (!path_len || IS_SLASH(path[path_len - 1])) { trailing_slash = ""; } else { trailing_slash = "/"; } - (void)snprintf(opened_path, MAXPATHLEN, "%s%s%sXXXXXX", path, trailing_slash, pfx); + if (spprintf(&opened_path, 0, "%s%s%sXXXXXX", path, trailing_slash, pfx) >= MAXPATHLEN) { + efree(opened_path); + return -1; + } #ifdef PHP_WIN32 if (GetTempFileName(path, pfx, 0, opened_path)) { -- 2.50.1