Skip to content

Fix the argument numbers of the hostname and community errors in snmp functions - #25590

Open
lacatoire wants to merge 1 commit into
php:PHP-8.5from
lacatoire:fix/snmp-hostname-argument-number-PHP-8.5
Open

lacatoire wants to merge 1 commit into
php:PHP-8.5from
lacatoire:fix/snmp-hostname-argument-number-PHP-8.5

Conversation

@lacatoire

@lacatoire lacatoire commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

snmp_session_init() reports the hostname as argument 2 and the community as argument 3, which is only right for SNMP::__construct(). The procedural functions take the hostname first, so snmpget() and the other snmp functions name the wrong parameter. Pass the position of the hostname instead, as master already does.

To reproduce

try {
    snmpget("a\0b", 'public', '.1.3.6.1.2.1.1.5.0');
} catch (ValueError $e) {
    echo $e->getMessage(), "\n";
}
try {
    snmpget('127.0.0.1', '', '.1.3.6.1.2.1.1.5.0');
} catch (ValueError $e) {
    echo $e->getMessage(), "\n";
}

PHP 8.5.4

Before:

snmpget(): Argument #2 ($community) must not contain any null bytes
snmpget(): Argument #3 ($object_id) must not be empty

After:

snmpget(): Argument #1 ($hostname) must not contain any null bytes
snmpget(): Argument #2 ($community) must not be empty

… functions

snmp_session_init() reported the hostname as argument 2 and the community
as argument 3, which is only right for SNMP::__construct(). The procedural
functions take the hostname first, so snmpget() and the other snmp*_get(),
set and walk functions named the wrong parameter. Pass the position of the
hostname instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant