]> granicus.if.org Git - php/commitdiff
Fixed bug #44501 (LOCK_EX mode in file_put_contents() is impropertly
authorIlia Alshanetsky <iliaa@php.net>
Wed, 26 Mar 2008 23:06:47 +0000 (23:06 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Wed, 26 Mar 2008 23:06:47 +0000 (23:06 +0000)
handled in combination with url wrappers)

ext/standard/file.c

index 0fce31af2f6a4761c9557d1d66fd45c38c6c4ac7..db783325eeeda6ec00f079de2f5a0bff5706b94f 100644 (file)
@@ -596,6 +596,13 @@ PHP_FUNCTION(file_put_contents)
        if (flags & PHP_FILE_APPEND) {
                mode[0] = 'a';
        } else if (flags & LOCK_EX) {
+               /* check to make sure we are dealing with a regular file */
+               if (php_memnstr(filename, "://", sizeof("://") - 1, filename + filename_len)) {
+                       if (strncasecmp(filename, "file://", sizeof("file://") - 1)) {
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Exclusive locks may only be set for regular files");
+                               RETURN_FALSE;
+                       }
+               }
                mode[0] = 'c';
        }
        mode[2] = '\0';