Skip to content

Enforce zero arity in apache_get_version() and apache_get_modules() - #23102

Merged
Girgias merged 1 commit into
php:masterfrom
lacatoire:fix/apache-sapi-zero-arity
Aug 7, 2026
Merged

Enforce zero arity in apache_get_version() and apache_get_modules()#23102
Girgias merged 1 commit into
php:masterfrom
lacatoire:fix/apache-sapi-zero-arity

Conversation

@lacatoire

@lacatoire lacatoire commented Aug 7, 2026

Copy link
Copy Markdown
Member

Both functions are declared with no parameters in sapi/apache2handler/php_functions.stub.php, and the generated arginfo agrees, but neither implementation calls ZEND_PARSE_PARAMETERS_NONE(), so extra positional arguments are silently accepted.

Served by php:8.4-apache and php:8.5-apache (PHP 8.4.24 and 8.5.9, Apache 2.4.68), identical on both:

<?php
var_dump(apache_get_version(1, 2, 3));
var_dump(apache_request_headers(1));
string(22) "Apache/2.4.68 (Debian)"

Fatal error: Uncaught ArgumentCountError: apache_request_headers() expects exactly 0 arguments, 1 given

The first call should throw like the second one. Every other zero-arity function of this SAPI does enforce its arity, and so does PHP_FUNCTION(apache_get_modules) in sapi/litespeed/lsapi_main.c:1710, so the two SAPIs currently disagree on whether apache_get_modules(1) is an error.

No stub or arginfo change is needed. Targeting master rather than a stable branch, since the change turns a silently accepted call into an ArgumentCountError.

Sources:

  • 11a9574 "Convert more zend_parse_parameters_none() to fast ZPP" converted the existing call sites in this file; these two never had one, so the sweep did not reach them.

Both functions are declared with no parameters in the stub, but neither
implementation called ZEND_PARSE_PARAMETERS_NONE(), so extra positional
arguments were silently accepted instead of raising ArgumentCountError.

Every other zero-arity function of the same SAPI (apache_request_headers(),
apache_response_headers(), getallheaders()) already enforces its arity, and
so does the litespeed implementation of apache_get_modules(). No stub or
arginfo change is needed.
@Girgias
Girgias merged commit b2cf460 into php:master Aug 7, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants