From f0d321e9477ceb96f9d856f3d5a879e0bfa42b1b Mon Sep 17 00:00:00 2001 From: Arshid Date: Fri, 6 Feb 2026 14:37:54 +0530 Subject: [PATCH 1/5] [mysqli] Simply if -> RETURN_TRUE/FALSE with RETURN_BOOL() (GH-21149) --- ext/mysqli/mysqli_api.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index 77a06370cc73..7af90f665854 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -1410,10 +1410,7 @@ PHP_FUNCTION(mysqli_stmt_send_long_data) RETURN_THROWS(); } - if (mysql_stmt_send_long_data(stmt->stmt, param_nr, data, data_len)) { - RETURN_FALSE; - } - RETURN_TRUE; + RETURN_BOOL(!mysql_stmt_send_long_data(stmt->stmt, param_nr, data, data_len)); } /* }}} */ @@ -1552,10 +1549,7 @@ PHP_FUNCTION(mysqli_stmt_reset) MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID); - if (mysql_stmt_reset(stmt->stmt)) { - RETURN_FALSE; - } - RETURN_TRUE; + RETURN_BOOL(!mysql_stmt_reset(stmt->stmt)); } /* }}} */ From 51158bbe9071ff972dfd4fb9fc17734921a44f21 Mon Sep 17 00:00:00 2001 From: Arshid Date: Fri, 6 Feb 2026 14:39:40 +0530 Subject: [PATCH 2/5] [win32] Use RETURN_BOOL() in sapi_windows_set_ctrl_handler() (GH-21148) --- win32/signal.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/win32/signal.c b/win32/signal.c index 49a7c1cc0c91..89548a2405c4 100644 --- a/win32/signal.c +++ b/win32/signal.c @@ -131,10 +131,7 @@ PHP_FUNCTION(sapi_windows_set_ctrl_handler) if (!ZEND_FCI_INITIALIZED(fci)) { zval_ptr_dtor(&ctrl_handler); ZVAL_UNDEF(&ctrl_handler); - if (!SetConsoleCtrlHandler(NULL, add)) { - RETURN_FALSE; - } - RETURN_TRUE; + RETURN_BOOL(SetConsoleCtrlHandler(NULL, add)); } if (!SetConsoleCtrlHandler(NULL, FALSE) || !SetConsoleCtrlHandler(php_win32_signal_system_ctrl_handler, add)) { From d3e470331018a8f519cc0ce980ece29a723594e0 Mon Sep 17 00:00:00 2001 From: Arshid Date: Fri, 6 Feb 2026 14:42:33 +0530 Subject: [PATCH 3/5] [standard] Simply if -> RETURN_TRUE/FALSE with RETURN_BOOL() (GH-21147) --- ext/standard/dns_win32.c | 6 +----- ext/standard/file.c | 11 +++-------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/ext/standard/dns_win32.c b/ext/standard/dns_win32.c index 1f7c6c0146e4..8caf5813395c 100644 --- a/ext/standard/dns_win32.c +++ b/ext/standard/dns_win32.c @@ -116,11 +116,7 @@ PHP_FUNCTION(dns_check_record) status = DnsQuery_A(hostname, type, DNS_QUERY_STANDARD, NULL, &pResult, NULL); - if (status) { - RETURN_FALSE; - } - - RETURN_TRUE; + RETURN_BOOL(!status); } /* }}} */ diff --git a/ext/standard/file.c b/ext/standard/file.c index bd6ee252875e..a7b73f1fe56e 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -1016,10 +1016,8 @@ PHPAPI PHP_FUNCTION(fflush) ZEND_PARSE_PARAMETERS_END(); ret = php_stream_flush(stream); - if (ret) { - RETURN_FALSE; - } - RETURN_TRUE; + + RETURN_BOOL(!ret); } /* }}} */ @@ -1032,10 +1030,7 @@ PHPAPI PHP_FUNCTION(rewind) PHP_Z_PARAM_STREAM(stream) ZEND_PARSE_PARAMETERS_END(); - if (-1 == php_stream_rewind(stream)) { - RETURN_FALSE; - } - RETURN_TRUE; + RETURN_BOOL(-1 != php_stream_rewind(stream)); } /* }}} */ From 6bd97e72b719599b3110fd5ec543b2996f52ba63 Mon Sep 17 00:00:00 2001 From: arshidkv12 Date: Sat, 31 Jan 2026 21:14:39 +0530 Subject: [PATCH 4/5] ext/posix: validate permissions argument in posix_mkfifo() close GH-21102 --- NEWS | 1 + ext/posix/posix.c | 5 +++ .../tests/posix_mkfifo_invalid_mode.phpt | 36 +++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 ext/posix/tests/posix_mkfifo_invalid_mode.phpt diff --git a/NEWS b/NEWS index b19b09c21442..0872d8dc542a 100644 --- a/NEWS +++ b/NEWS @@ -80,6 +80,7 @@ PHP NEWS - Posix: . Added validity check to the flags argument for posix_access(). (arshidkv12) + . Added validity check to the permissions argument for posix_mkfifo(). (arshidkv12) - Reflection: . Fixed bug GH-20217 (ReflectionClass::isIterable() incorrectly returns true diff --git a/ext/posix/posix.c b/ext/posix/posix.c index 76e14f6ecb0c..a81372349fd4 100644 --- a/ext/posix/posix.c +++ b/ext/posix/posix.c @@ -621,6 +621,11 @@ PHP_FUNCTION(posix_mkfifo) RETURN_FALSE; } + if (mode < 0 || (mode & ~07777)) { + zend_argument_value_error(2, "must be between 0 and 0o7777"); + RETURN_THROWS(); + } + result = mkfifo(ZSTR_VAL(path), mode); if (result < 0) { POSIX_G(last_error) = errno; diff --git a/ext/posix/tests/posix_mkfifo_invalid_mode.phpt b/ext/posix/tests/posix_mkfifo_invalid_mode.phpt new file mode 100644 index 000000000000..5c9f251adfca --- /dev/null +++ b/ext/posix/tests/posix_mkfifo_invalid_mode.phpt @@ -0,0 +1,36 @@ +--TEST-- +posix_mkfifo(): invalid mode argument +--SKIPIF-- + +--FILE-- +getMessage(), "\n"; +} + +// Too large mode +try { + posix_mkfifo(__DIR__ . "/testfifo2", 010000); // > 07777 +} catch (ValueError $e) { + echo $e->getMessage(), "\n"; +} + +// Garbage bits +try { + posix_mkfifo(__DIR__ . "/testfifo3", 020000); // S_IFCHR bit +} catch (ValueError $e) { + echo $e->getMessage(), "\n"; +} +?> +--EXPECTF-- +posix_mkfifo(): Argument #2 ($permissions) must be between 0 and 0o7777 +posix_mkfifo(): Argument #2 ($permissions) must be between 0 and 0o7777 +posix_mkfifo(): Argument #2 ($permissions) must be between 0 and 0o7777 From 52e9436629061a7a5280011abbb104f4be9a7e2b Mon Sep 17 00:00:00 2001 From: David Carlier Date: Fri, 6 Feb 2026 12:55:59 +0000 Subject: [PATCH 5/5] [ci skip] ext/posix: forgotten UPGRADING notes for posix_access()/posix_mkfifo(). --- UPGRADING | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/UPGRADING b/UPGRADING index 830709b2ae23..8a1c61b9192c 100644 --- a/UPGRADING +++ b/UPGRADING @@ -81,6 +81,12 @@ PHP 8.6 UPGRADE NOTES - Phar: . Phar::mungServer() now supports reference values. +- Posix: + . posix_access() now throws a ValueError exception if the flags + argument is invalid. + . posix_mkfifo() now throws a ValueError exception if the permissions + argument is invalid. + - Sockets: . socket_addrinfo_lookup() now has an additional optional argument $error when not null, and on failure, gives the error code (one of the EAI_*