[php-src] PR #21342: ext/snmp: fix infinite loop in snprint_value retry when val_len is zero
| From: | thomasvincent | Date: | Wed, 04 Mar 2026 16:51:36 +0000 |
| Subject: | [php-src] PR #21342: ext/snmp: fix infinite loop in snprint_value retry when val_len is zero | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-35087@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/21342
Author: thomasvincent
When an SNMP variable has
val_len == 0 (valid for empty octet strings),
the snprint_value retry loop doubles val_len on each iteration
(val_len *= 2). Since 0 * 2 == 0, val_len never grows, the
allocated buffer stays at 1 byte, and the 512k break condition is
never reached. This causes an infinite loop consuming CPU.
Fix by clamping val_len to at least sizeof(sbuf) before the loop,
ensuring the doubling produces meaningful growth past the initial stack
buffer size.