Skip to content

Commit 17d22a5

Browse files
author
Ilia Alshanetsky
committed
Fixed bug #44501 (LOCK_EX mode in file_put_contents() is impropertly
handled in combination with url wrappers)
1 parent 073b6ea commit 17d22a5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

ext/standard/file.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,13 @@ PHP_FUNCTION(file_put_contents)
596596
if (flags & PHP_FILE_APPEND) {
597597
mode[0] = 'a';
598598
} else if (flags & LOCK_EX) {
599+
/* check to make sure we are dealing with a regular file */
600+
if (php_memnstr(filename, "://", sizeof("://") - 1, filename + filename_len)) {
601+
if (strncasecmp(filename, "file://", sizeof("file://") - 1)) {
602+
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Exclusive locks may only be set for regular files");
603+
RETURN_FALSE;
604+
}
605+
}
599606
mode[0] = 'c';
600607
}
601608
mode[2] = '\0';

0 commit comments

Comments
 (0)