mirror of
https://github.com/php/php-src.git
synced 2025-08-20 17:34:35 +02:00
MFB: Fixed handling of extremely long paths inside tempnam() function.
This commit is contained in:
parent
47343620cb
commit
45b278cc34
1 changed files with 4 additions and 5 deletions
|
@ -114,17 +114,16 @@ static int php_do_open_temporary_file(const char *path, const char *pfx, char **
|
||||||
|
|
||||||
path_len = strlen(path);
|
path_len = strlen(path);
|
||||||
|
|
||||||
if (!(opened_path = emalloc(MAXPATHLEN))) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!path_len || IS_SLASH(path[path_len - 1])) {
|
if (!path_len || IS_SLASH(path[path_len - 1])) {
|
||||||
trailing_slash = "";
|
trailing_slash = "";
|
||||||
} else {
|
} else {
|
||||||
trailing_slash = "/";
|
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
|
#ifdef PHP_WIN32
|
||||||
if (GetTempFileName(path, pfx, 0, opened_path)) {
|
if (GetTempFileName(path, pfx, 0, opened_path)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue