[php-src] PHP-8.5: Merge branch 'PHP-8.4' into PHP-8.5
| From: | David Carlier | Date: | Fri, 13 Nov 2026 06:22:59 +0000 |
| Subject: | [php-src] PHP-8.5: Merge branch 'PHP-8.4' into PHP-8.5 | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-143677@lists.php.net to get a copy of this message | ||
Author: David Carlier (devnexen)
Date: 2026-11-13T06:21:08Z
Commit: https://github.com/php/php-src/commit/9afb52d0d1df07e77c5c37ddf5c756c6fdcb11d2
Raw diff: https://github.com/php/php-src/commit/9afb52d0d1df07e77c5c37ddf5c756c6fdcb11d2.diff
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
ext/snmp: Copy the context name in SNMP::setSecurity()
Changed paths:
A ext/snmp/tests/snmp-object-setSecurity-contextName.phpt
M ext/snmp/snmp.c
Diff:
diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c
index 672ac9a94b4f..b34430b32118 100644
--- a/ext/snmp/snmp.c
+++ b/ext/snmp/snmp.c
@@ -160,6 +160,7 @@ static void snmp_session_free(php_snmp_session **session) /* {{{ */
PHP_SNMP_SESSION_FREE(community);
PHP_SNMP_SESSION_FREE(securityName);
PHP_SNMP_SESSION_FREE(contextEngineID);
+ PHP_SNMP_SESSION_FREE(contextName);
efree(*session);
*session = NULL;
}
@@ -1213,7 +1214,10 @@ static ZEND_ATTRIBUTE_NONNULL_ARGS(2) bool snmp_session_set_security(struct
snmp
/* Setting contextName if specified */
if (contextName) {
- session->contextName = ZSTR_VAL(contextName);
+ if (session->contextName) {
+ efree(session->contextName);
+ }
+ session->contextName = estrndup(ZSTR_VAL(contextName), ZSTR_LEN(contextName));
session->contextNameLen = ZSTR_LEN(contextName);
}
diff --git a/ext/snmp/tests/snmp-object-setSecurity-contextName.phpt
b/ext/snmp/tests/snmp-object-setSecurity-contextName.phpt
new file mode 100644
index 000000000000..95055e2be8f3
--- /dev/null
+++ b/ext/snmp/tests/snmp-object-setSecurity-contextName.phpt
@@ -0,0 +1,22 @@
+--TEST--
+SNMP::setSecurity() - the context name is copied
+--EXTENSIONS--
+snmp
+--SKIPIF--
+<?php
+require_once(__DIR__.'/skipif.inc');
+?>
+--FILE--
+<?php
+require_once(__DIR__.'/snmp_include.inc');
+
+$session = new SNMP(SNMP::VERSION_3, $hostname, $rwuser, $timeout, $retries);
+$context = str_repeat('c', 5) . random_int(10, 99);
+$session->setSecurity('authPriv', 'MD5', $auth_pass, 'AES',
$priv_pass, $context);
+unset($context);
+// The agent does not know this context, only the lifetime of the name matters.
+var_dump(@$session->get('.1.3.6.1.2.1.1.1.0'));
+$session->close();
+?>
+--EXPECT--
+bool(false)