]> granicus.if.org Git - php/commitdiff
Revert "Explicitly validate popen mode"
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 6 Aug 2020 19:53:13 +0000 (21:53 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 6 Aug 2020 19:53:13 +0000 (21:53 +0200)
This reverts commit ab36540bddb63139c3da9a9da5e5feacdf7bf7bf.

Causes a test failure on Windows.

ext/standard/file.c
ext/standard/tests/file/popen_pclose_error.phpt

index 88ffba8102928feb6ffd8d977553ca4228be5343..98578376b001c90433bdeb7f431f9d3b29e775db 100644 (file)
@@ -930,18 +930,10 @@ PHP_FUNCTION(popen)
                char *z = memchr(posix_mode, 'b', mode_len);
                if (z) {
                        memmove(z, z + 1, mode_len - (z - posix_mode));
-                       mode_len--;
                }
        }
 #endif
 
-       /* Musl only partially validates the mode. Manually check it to ensure consistent behavior. */
-       if (mode_len != 1 || (*posix_mode != 'r' && *posix_mode != 'w')) {
-               php_error_docref2(NULL, command, posix_mode, E_WARNING, "Invalid mode");
-               efree(posix_mode);
-               RETURN_FALSE;
-       }
-
        fp = VCWD_POPEN(command, posix_mode);
        if (!fp) {
                php_error_docref2(NULL, command, posix_mode, E_WARNING, "%s", strerror(errno));
index 07132808701bdd0b6c0ec0f99ada368e713ee4d0..2f05e7788d982203308df27964dfdab5180c7ffb 100644 (file)
@@ -22,7 +22,7 @@ unlink($file_path."/popen.tmp");
 --EXPECTF--
 *** Testing for error conditions ***
 
-Warning: popen(abc.txt,rw): Invalid mode in %s on line %d
+Warning: popen(abc.txt,rw): %s on line %d
 bool(false)
 
 --- Done ---