[php-src] PHP-8.6: ext/snmp: Fix the timeout argument number in snmp3_set() errors

From: Date: Thu, 19 Nov 2026 13:22:18 +0000
Subject: [php-src] PHP-8.6: ext/snmp: Fix the timeout argument number in snmp3_set() errors
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-143873@lists.php.net to get a copy of this message
Author: lacatoire (lacatoire) Committer: David Carlier (devnexen) Date: 2026-11-19T13:20:34Z Commit: https://github.com/php/php-src/commit/1a8b184b8568cd347cee07a12791f429e6f8b7bf Raw diff: https://github.com/php/php-src/commit/1a8b184b8568cd347cee07a12791f429e6f8b7bf.diff ext/snmp: Fix the timeout argument number in snmp3_set() errors snmp3_set() names the wrong argument when $timeout or $retries is invalid: $timeout is argument 11 and $retries argument 12, but the errors cite 10 and 11. Close GH-25368 Changed paths: A ext/snmp/tests/snmp3_set_timeout_argument.phpt M NEWS M ext/snmp/snmp.c Diff: diff --git a/NEWS b/NEWS index ca38bc37b78a..8f03a2a68930 100644 --- a/NEWS +++ b/NEWS @@ -125,6 +125,10 @@ PHP NEWS methods, which crashed when called for the ones of internal classes. (Nicolas Grekas) +- SNMP: + . Fixed snmp3_set() citing the wrong argument number for an invalid $timeout + or $retries. (lacatoire) + - SOAP: . Fixed bug GH-25267 (NULL dereference in to_xml_any() with integer key). (lazerg) diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c index b34430b32118..0e9459185c45 100644 --- a/ext/snmp/snmp.c +++ b/ext/snmp/snmp.c @@ -1277,7 +1277,7 @@ static void php_snmp(INTERNAL_FUNCTION_PARAMETERS, int st, int version) Z_PARAM_LONG(retries) ZEND_PARSE_PARAMETERS_END(); - timeout_argument_offset = 10; + timeout_argument_offset = 11; } else { /* SNMP_CMD_GET * SNMP_CMD_GETNEXT diff --git a/ext/snmp/tests/snmp3_set_timeout_argument.phpt b/ext/snmp/tests/snmp3_set_timeout_argument.phpt new file mode 100644 index 000000000000..2a3c63ed09ef --- /dev/null +++ b/ext/snmp/tests/snmp3_set_timeout_argument.phpt @@ -0,0 +1,18 @@ +--TEST-- +snmp3_set() - an invalid timeout or retries cites the right argument +--EXTENSIONS-- +snmp +--FILE-- +<?php +$oid = '.1.3.6.1.2.1.1.5.0'; +foreach ([[-2, 1], [100, -2]] as [$timeout, $retries]) { + try { + snmp3_set('127.0.0.1', 'user', 'noAuthNoPriv', '', '', '', '', $oid, 's', 'x', $timeout, $retries); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), "\n"; + } +} +?> +--EXPECTF-- +ValueError: snmp3_set(): Argument #11 ($timeout) must be between -1 and %d +ValueError: snmp3_set(): Argument #12 ($retries) must be between -1 and %d

« previous php.cvs (#143873) next »