Commit eff7f7e
committed
ext/openssl: Reorder reneg rate-limit decay to avoid integer divide to zero
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 that brings the operand into a useful range. Guard
against window <= 0 to keep the divide safe under user-supplied values
the existing init handler does not validate.1 parent 05afc37 commit eff7f7e
1 file changed
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1131 | 1131 | | |
1132 | 1132 | | |
1133 | 1133 | | |
1134 | | - | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
1135 | 1137 | | |
1136 | 1138 | | |
1137 | 1139 | | |
| |||
0 commit comments