[php-src] PR #23553: ext/pcntl: fix an off by one bound and a parameter the parser made required
| From: | lacatoire | Date: | Thu, 03 Sep 2026 13:22:04 +0000 |
| Subject: | [php-src] PR #23553: ext/pcntl: fix an off by one bound and a parameter the parser made required | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-38279@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/23553
Author: lacatoire
Two unrelated slips in
ext/pcntl/pcntl.c, together because they touch the same file.
pcntl_setcpuaffinity() rejects cpu >= maxcpus but advertises
maxcpus as the inclusive upper bound, so on a 16-CPU host id 16 is refused by a message
saying "between 0 and 16". It now prints maxcpus - 1. The same line printed
maxcpus, a zend_long, with ZEND_ULONG_FMT; corrected to
ZEND_LONG_FMT, since sysconf() can return -1.
pcntl_setqos_class() declares $qos_class optional with a default of
Pcntl\QosClass::Default, but its ZPP block was (1, 1) and qos
was left uninitialised, so calling it with no argument raised an ArgumentCountError and
the declared default was unreachable. It now parses (0, 1) with
Z_PARAM_OPTIONAL and initialises qos beforehand, as bcround()
does for its optional enum parameter. This half is macOS-only and could not be exercised here.
The new test reads the bound out of the message rather than hardcoding a cpu count, then checks that
the advertised bound is accepted and the next id refused; it fails on the current code. Master only,
as the exception message changes.