Skip to content

Commit 61cf7d4

Browse files
devnexenGirgias
authored andcommitted
posix_pathconf throwing ValueError on empty path
1 parent ecc880f commit 61cf7d4

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

ext/posix/posix.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,11 @@ PHP_FUNCTION(posix_pathconf)
12081208
Z_PARAM_LONG(name);
12091209
ZEND_PARSE_PARAMETERS_END();
12101210

1211-
if (path_len == 0 || php_check_open_basedir(path)) {
1211+
if (path_len == 0) {
1212+
zend_argument_value_error(1, "cannot be empty");
1213+
RETURN_THROWS();
1214+
} else if (php_check_open_basedir(path)) {
1215+
php_error_docref(NULL, E_WARNING, "Invalid path supplied: %s", path);
12121216
RETURN_FALSE;
12131217
}
12141218

ext/posix/tests/posix_pathconf.phpt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@ Test posix_pathconf
44
posix
55
--FILE--
66
<?php
7-
var_dump(posix_pathconf('', POSIX_PC_PATH_MAX));
7+
try {
8+
posix_pathconf('', POSIX_PC_PATH_MAX);
9+
} catch (\ValueError $e) {
10+
echo $e->getMessage(). "\n";
11+
}
812
var_dump(posix_pathconf(str_repeat('non_existent', 4096), POSIX_PC_NAME_MAX));
913
var_dump(posix_errno() != 0);
1014
var_dump(posix_pathconf(sys_get_temp_dir(), POSIX_PC_PATH_MAX));
1115
?>
1216
--EXPECTF--
13-
bool(false)
17+
posix_pathconf(): Argument #1 ($path) cannot be empty
1418
bool(false)
1519
bool(true)
1620
int(%d)

0 commit comments

Comments
 (0)