[php-src] PR #21341: ext/snmp: fix buffer overflow in suffix-as-keys OID construction

From: Date: Wed, 04 Mar 2026 16:50:57 +0000
Subject: [php-src] PR #21341: ext/snmp: fix buffer overflow in suffix-as-keys OID construction
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-35086@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/21341 Author: thomasvincent The suffix-as-keys code path in php_snmp builds a dotted OID suffix string by repeatedly calling snprintf into a temporary buffer and appending with strcat into the fixed 2048-byte buf2 array. There is no bounds check, so a deeply nested OID with many large numeric components from a malicious SNMP agent could overflow the stack buffer. Replace the strcat loop with direct snprintf into buf2 at a tracked offset, breaking out of the loop if the buffer would be exhausted. The MAX_OID_LEN (128) with maximum-length 32-bit components (10 digits plus dot each) can produce up to 1408 bytes of suffix text, which fits within the 2048-byte buffer under normal conditions. This patch adds the safety net for the pathological case.

« previous php.git-pulls (#35086) next »