Skip to content

Commit

Permalink
Fix GH-12838: [SOAP] Temporary WSDL cache files not being deleted
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nielsdos committed Dec 1, 2023
1 parent f203edd commit 4eee81b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions NEWS
Expand Up @@ -56,6 +56,10 @@ PHP NEWS
- PHPDBG:
. Fixed bug GH-12675 (MEMORY_LEAK in phpdbg_prompt.c). (nielsdos)

- SOAP:
. Fixed bug GH-12838 ([SOAP] Temporary WSDL cache files not being deleted).
(nielsdos)

- SPL:
. Fixed bug GH-12721 (SplFileInfo::getFilename() segfault in combination
with GlobIterator and no directory separator). (nielsdos)
Expand Down
4 changes: 3 additions & 1 deletion ext/soap/php_sdl.c
Expand Up @@ -2381,7 +2381,9 @@ static void add_sdl_to_cache(const char *fn, const char *uri, time_t t, sdlPtr s
/* Make sure that incomplete files (e.g. due to disk space issues, see bug #66150) are not utilised. */
if (valid_file) {
/* This is allowed to fail, this means that another process was raced to create the file. */
(void) VCWD_RENAME(ZSTR_VAL(temp_file_path), fn);
if (VCWD_RENAME(ZSTR_VAL(temp_file_path), fn) < 0) {
VCWD_UNLINK(ZSTR_VAL(temp_file_path));
}
}

smart_str_free(&buf);
Expand Down

0 comments on commit 4eee81b

Please sign in to comment.