@@ -12,11 +12,12 @@ if (getenv('SKIP_ASAN')) die('skip Timeouts under ASAN');
1212require_once (__DIR__ .'/snmp_include.inc ' );
1313
1414/* Exercise the suffix-as-keys code path (SNMP_USE_SUFFIX_AS_KEYS |
15- * SNMP_CMD_WALK). The walk OID is chosen so the returned subidentifiers
16- * form a multi-component suffix, driving multiple iterations of the
17- * snprintf loop that GH-21341 replaced the strcat loop with. */
15+ * SNMP_CMD_WALK). Walking .1.3.6.1.2.1 (mib-2) returns entries whose
16+ * suffixes have multiple components (e.g. "1.1.0", "2.1.1.0"), driving
17+ * several iterations of the snprintf loop that GH-21341 replaced the
18+ * strcat loop with. */
1819$ session = new SNMP (SNMP ::VERSION_2c, $ hostname , $ community , $ timeout , $ retries );
19- $ result = $ session ->walk ('.1.3.6.1.2.1.1 ' , /* suffix_as_keys */ true );
20+ $ result = $ session ->walk ('.1.3.6.1.2.1 ' , /* suffix_as_keys */ true );
2021
2122var_dump (is_array ($ result ));
2223var_dump (count ($ result ) > 0 );
@@ -28,10 +29,18 @@ $bad = array_filter(array_keys($result), static function (string $k): bool {
2829});
2930var_dump (count ($ bad ) === 0 );
3031
32+ /* No key may end with '.': the trailing-dot removal (buf2[pos-1] = '\0')
33+ * must fire correctly on every entry. */
34+ $ trailing = array_filter (array_keys ($ result ), static function (string $ k ): bool {
35+ return $ k !== '' && $ k [-1 ] === '. ' ;
36+ });
37+ var_dump (count ($ trailing ) === 0 );
38+
3139var_dump ($ session ->close ());
3240?>
3341--EXPECT--
3442bool(true)
3543bool(true)
3644bool(true)
3745bool(true)
46+ bool(true)
0 commit comments