Skip to content

Commit 6ab90f9

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4: Fix leak of resolved address list in netsnmp_session_init()
2 parents cf18c77 + 3704b9d commit 6ab90f9

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

ext/snmp/snmp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,7 @@ static bool snmp_session_init(php_snmp_session **session_p, int version, zend_st
957957

958958
if (strlen(session->peername) == 0) {
959959
php_error_docref(NULL, E_WARNING, "Unknown failure while resolving '%s'", ZSTR_VAL(hostname));
960+
php_network_freeaddresses(psal);
960961
return false;
961962
}
962963
/* XXX FIXME
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
snmp: resolved address list is freed when peername resolution drains empty
3+
--EXTENSIONS--
4+
snmp
5+
--FILE--
6+
<?php
7+
// Bracketed (IPv6) syntax over an IPv4-only literal forces IPv6 resolution,
8+
// which drains to no usable address, hitting the "Unknown failure while
9+
// resolving" path. That path must free the address list from
10+
// php_network_getaddresses() (it previously leaked it). No SNMP agent needed:
11+
// the function fails at peername resolution before any query is sent.
12+
var_dump(snmpget("[127.0.0.1]", "public", ".1.3.6.1.2.1.1.1.0"));
13+
?>
14+
--EXPECTF--
15+
Warning: snmpget(): Unknown failure while resolving '[127.0.0.1]' in %s on line %d
16+
bool(false)

0 commit comments

Comments
 (0)