Skip to content

Commit 4eee81b

Browse files
committed
Fix GH-12838: [SOAP] Temporary WSDL cache files not being deleted
If there are two users that can execute the script that caches a WSDL, but the script is owned by a single user, then the caching code will name the cached file with the file owner username and a hash of the uri. When one of the two tries to rename the file created by the other process, this does not work because it has no permission to do so. This then leaves temporary files floating in the temp directory. To fix the immediate problem, unlink the file after rename has failed. On the long term, this has to be fixed by taking the username of the process instead of the username of the file owner. Closes GH-12841.
1 parent f203edd commit 4eee81b

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ PHP NEWS
5656
- PHPDBG:
5757
. Fixed bug GH-12675 (MEMORY_LEAK in phpdbg_prompt.c). (nielsdos)
5858

59+
- SOAP:
60+
. Fixed bug GH-12838 ([SOAP] Temporary WSDL cache files not being deleted).
61+
(nielsdos)
62+
5963
- SPL:
6064
. Fixed bug GH-12721 (SplFileInfo::getFilename() segfault in combination
6165
with GlobIterator and no directory separator). (nielsdos)

ext/soap/php_sdl.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2381,7 +2381,9 @@ static void add_sdl_to_cache(const char *fn, const char *uri, time_t t, sdlPtr s
23812381
/* Make sure that incomplete files (e.g. due to disk space issues, see bug #66150) are not utilised. */
23822382
if (valid_file) {
23832383
/* This is allowed to fail, this means that another process was raced to create the file. */
2384-
(void) VCWD_RENAME(ZSTR_VAL(temp_file_path), fn);
2384+
if (VCWD_RENAME(ZSTR_VAL(temp_file_path), fn) < 0) {
2385+
VCWD_UNLINK(ZSTR_VAL(temp_file_path));
2386+
}
23852387
}
23862388

23872389
smart_str_free(&buf);

0 commit comments

Comments
 (0)