Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ PHP NEWS
. Mark Phar::buildFromIterator() base directory argument as a path.
(ndossche)

- Posix:
. Added validity check to the flags argument for posix_access(). (arshidkv12)

- Reflection:
. Fixed bug GH-20217 (ReflectionClass::isIterable() incorrectly returns true
for classes with property hooks). (alexandre-daubois)
Expand Down
11 changes: 3 additions & 8 deletions ext/pgsql/pgsql.c
Original file line number Diff line number Diff line change
Expand Up @@ -3023,10 +3023,7 @@ PHP_FUNCTION(pg_lo_export)

pgsql = link->conn;

if (lo_export(pgsql, oid, ZSTR_VAL(file_out)) == -1) {
RETURN_FALSE;
}
RETURN_TRUE;
RETURN_BOOL(lo_export(pgsql, oid, ZSTR_VAL(file_out)) != -1);
}
/* }}} */

Expand Down Expand Up @@ -3863,10 +3860,8 @@ PHP_FUNCTION(pg_connection_reset)
pgsql = link->conn;

PQreset(pgsql);
if (PQstatus(pgsql) == CONNECTION_BAD) {
RETURN_FALSE;
}
RETURN_TRUE;

RETURN_BOOL(PQstatus(pgsql) != CONNECTION_BAD);
}
/* }}} */

Expand Down
9 changes: 9 additions & 0 deletions ext/posix/posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,15 @@ PHP_FUNCTION(posix_access)
RETURN_FALSE;
}

if (mode < 0 || (mode & ~(F_OK | R_OK | W_OK | X_OK))) {
zend_argument_value_error(
2,
"must be a bitmask of POSIX_F_OK, POSIX_R_OK, POSIX_W_OK, and POSIX_X_OK"
);
efree(path);
RETURN_THROWS();
}

ret = access(path, mode);
efree(path);

Expand Down
54 changes: 54 additions & 0 deletions ext/posix/tests/posix_access_flags.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
--TEST--
posix_access() flag (mode) validation
--SKIPIF--
<?php
if (!function_exists("posix_access")) {
die("skip no posix_access()");
}
?>
--FILE--
<?php

$dir = __DIR__;
$testfile = "$dir/testfile.txt";

// Create a temporary file for valid access tests
file_put_contents($testfile, "hello");

try {
posix_access($testfile, -1);
} catch (ValueError $e) {
echo $e->getMessage(), "\n";
}

try {
posix_access($testfile, 01000); // S_ISVTX bit (sticky)
} catch (ValueError $e) {
echo $e->getMessage(), "\n";
}

try {
posix_access($testfile, 02000); // S_ISGID bit
} catch (ValueError $e) {
echo $e->getMessage(), "\n";
}

if (posix_access($testfile, POSIX_R_OK | POSIX_W_OK)) {
echo "Read/write access OK\n";
}

if (posix_access($testfile, POSIX_F_OK)) {
echo "File exists OK\n";
}

?>
--CLEAN--
<?php
@unlink(__DIR__ . '/testfile.txt');
?>
--EXPECTF--
posix_access(): Argument #2 ($flags) must be a bitmask of POSIX_F_OK, POSIX_R_OK, POSIX_W_OK, and POSIX_X_OK
posix_access(): Argument #2 ($flags) must be a bitmask of POSIX_F_OK, POSIX_R_OK, POSIX_W_OK, and POSIX_X_OK
posix_access(): Argument #2 ($flags) must be a bitmask of POSIX_F_OK, POSIX_R_OK, POSIX_W_OK, and POSIX_X_OK
Read/write access OK
File exists OK