Commit aee532f
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 the decay in double-precision floating point so user-controlled
reneg_limit and reneg_window values cannot trigger signed integer
overflow in elapsed_time * limit. Guard against window <= 0 to keep the
divide well-defined under values the existing init handler does not
validate.1 parent 05afc37 commit aee532f
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