[php-src] PR #22037: ext/openssl: Reorder reneg rate-limit decay to avoid integer divide to zero
| From: | iliaal | Date: | Wed, 13 May 2026 20:16:12 +0000 |
| Subject: | [php-src] PR #22037: ext/openssl: Reorder reneg rate-limit decay to avoid integer divide to zero | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-36118@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/22037
Author: iliaal
php_openssl_limit_handshake_reneg() computes the bucket decay as elapsed * (limit
/ window). Both operands are zend_long, so with the documented defaults
limit=2 and window=300 the inner division truncates to 0 and the decay
term collapses to 0 for every elapsed value. The leaky bucket stops leaking and the cap fires after
exactly limit renegotiations regardless of how widely spaced in time, not "limit
per window seconds" as documented.
Compute (elapsed * limit) / window so the truncation only applies once, after the
multiply brings the operand into a useful range. Guard against window <= 0 to keep
the divide safe under user-supplied values that the existing init handler does not validate.
The existing stream_server_reneg_limit.phpt (which exercises the limit=0
cap-fires-immediately path) continues to pass. A focused decay-arithmetic test requires
openssl s_client reneg choreography across several wall-clock seconds; deferring unless
reviewers want it.