Skip to content

Commit 7c84675

Browse files
committed
Revert "Explicitly validate popen mode"
This reverts commit ab36540. Causes a test failure on Windows.
1 parent 11274f5 commit 7c84675

File tree

2 files changed

+1
-9
lines changed

2 files changed

+1
-9
lines changed

ext/standard/file.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -930,18 +930,10 @@ PHP_FUNCTION(popen)
930930
char *z = memchr(posix_mode, 'b', mode_len);
931931
if (z) {
932932
memmove(z, z + 1, mode_len - (z - posix_mode));
933-
mode_len--;
934933
}
935934
}
936935
#endif
937936

938-
/* Musl only partially validates the mode. Manually check it to ensure consistent behavior. */
939-
if (mode_len != 1 || (*posix_mode != 'r' && *posix_mode != 'w')) {
940-
php_error_docref2(NULL, command, posix_mode, E_WARNING, "Invalid mode");
941-
efree(posix_mode);
942-
RETURN_FALSE;
943-
}
944-
945937
fp = VCWD_POPEN(command, posix_mode);
946938
if (!fp) {
947939
php_error_docref2(NULL, command, posix_mode, E_WARNING, "%s", strerror(errno));

ext/standard/tests/file/popen_pclose_error.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ unlink($file_path."/popen.tmp");
2222
--EXPECTF--
2323
*** Testing for error conditions ***
2424

25-
Warning: popen(abc.txt,rw): Invalid mode in %s on line %d
25+
Warning: popen(abc.txt,rw): %s on line %d
2626
bool(false)
2727

2828
--- Done ---

0 commit comments

Comments
 (0)