Skip to content

Commit 3ee8b39

Browse files
committed
Merge branch 'PHP-8.4'
2 parents 466f325 + 895c6d5 commit 3ee8b39

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

ext/snmp/snmp.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,6 +1660,10 @@ PHP_METHOD(SNMP, setSecurity)
16601660
zend_string *a1 = NULL, *a2 = NULL, *a3 = NULL, *a4 = NULL, *a5 = NULL, *a6 = NULL, *a7 = NULL;
16611661

16621662
snmp_object = Z_SNMP_P(object);
1663+
if (!snmp_object->session) {
1664+
zend_throw_error(NULL, "Invalid or uninitialized SNMP object");
1665+
RETURN_THROWS();
1666+
}
16631667

16641668
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|SSSSSS", &a1, &a2, &a3, &a4,&a5, &a6, &a7) == FAILURE) {
16651669
RETURN_THROWS();

ext/snmp/tests/gh17330.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
SNMP::setSecurity() segfault when the object had been closed.
3+
--EXTENSIONS--
4+
snmp
5+
--CREDITS--
6+
YuanchengJiang
7+
--FILE--
8+
<?php
9+
$session = new SNMP(SNMP::VERSION_2c, "localhost", 'timeout_community_432');
10+
$session->close();
11+
try {
12+
$session->setSecurity('authPriv', 'MD5', '', 'AES', '');
13+
} catch(Error $e) {
14+
echo $e->getMessage();
15+
}
16+
?>
17+
--EXPECT--
18+
Invalid or uninitialized SNMP object

0 commit comments

Comments
 (0)