From 105d6df5e2338c60067a98b39593db544af4e768 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Sun, 23 Aug 2026 19:51:40 +0530 Subject: [PATCH 1/3] Fix SNMP build with modern Net-SNMP API (#23419) --- ext/snmp/config.m4 | 7 +++++++ ext/snmp/snmp.c | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/ext/snmp/config.m4 b/ext/snmp/config.m4 index 22cab40adf3b..62ac5471da7a 100644 --- a/ext/snmp/config.m4 +++ b/ext/snmp/config.m4 @@ -51,6 +51,13 @@ if test "$PHP_SNMP" != "no"; then [AC_MSG_FAILURE([SNMP sanity check failed.])], [$SNMP_SHARED_LIBADD]) + dnl Check whether netsnmp_init_mib() exists. + PHP_CHECK_LIBRARY([$SNMP_LIBNAME], [netsnmp_init_mib], + [AC_DEFINE([HAVE_NETSNMP_INIT_MIB], [1], + [Define to 1 if the Net-SNMP library has the 'netsnmp_init_mib' function.])], + [], + [$SNMP_SHARED_LIBADD]) + dnl Check whether shutdown_snmp_logging() exists. PHP_CHECK_LIBRARY([$SNMP_LIBNAME], [shutdown_snmp_logging], [AC_DEFINE([HAVE_SHUTDOWN_SNMP_LOGGING], [1], diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c index bcca8d44de89..8fac85a236ab 100644 --- a/ext/snmp/snmp.c +++ b/ext/snmp/snmp.c @@ -1687,7 +1687,11 @@ PHP_FUNCTION(snmp_init_mib) shutdown_mib(); netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIBDIRS, ZSTR_VAL(mibdirs)); +#ifdef HAVE_NETSNMP_INIT_MIB + netsnmp_init_mib(); +#else init_mib(); +#endif } /* }}} */ @@ -2228,7 +2232,11 @@ static PHP_RSHUTDOWN_FUNCTION(snmp) if (mib_needs_reset) { shutdown_mib(); netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIBDIRS, NULL); +#ifdef HAVE_NETSNMP_INIT_MIB + netsnmp_init_mib(); +#else init_mib(); +#endif } return SUCCESS; From daf21f4630812168666bfba9ed7de710ebefae4f Mon Sep 17 00:00:00 2001 From: Weilin Du Date: Mon, 24 Aug 2026 00:01:11 +0800 Subject: [PATCH 2/3] [skip ci] NEWS: add entries for #23396 and #23306 --- NEWS | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/NEWS b/NEWS index a6c44c47bc44..2e7adae0d951 100644 --- a/NEWS +++ b/NEWS @@ -80,6 +80,13 @@ PHP NEWS . SessionHandler::validateId() is now implemented, so session.use_strict_mode applies to the built-in handler. (Girgias) +- Sodium: + . Fixed incorrect parameter name in sodium_add(), sodium_memcmp(), and + sodium_compare() length-mismatch error messages. (lacatoire) + +- Standard: + . Fixed incorrect parameter name in convert_uudecode() warning. (lacatoire) + - Zip: . Fixed bug GH-17787 (ZipArchive stream stops reading early when the archive is freed while the stream is still open). (Eyüp Can Akman) From 0870487b6256cbfbc12134cd52c599a92c1ac160 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Wed, 29 Jul 2026 12:03:18 -0400 Subject: [PATCH 3/3] ext/session: report a rejected session cookie header php_session_send_cookie() discarded the result of sapi_add_header_ex() and always returned SUCCESS. When the SAPI refuses a Set-Cookie header carrying CR or LF, the warning it emits can reach a userland error handler that calls session_destroy(), and php_session_reset_id() then appends the released PS(id). Return what sapi_add_header_ex() reports so the caller stops before touching session state again. Closes GH-22923 --- ext/session/session.c | 4 +-- .../session_start_cookie_header_rejected.phpt | 28 +++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 ext/session/tests/session_start_cookie_header_rejected.phpt diff --git a/ext/session/session.c b/ext/session/session.c index f03813c791d6..2073ea55fe1f 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -1499,10 +1499,10 @@ static zend_result php_session_send_cookie(void) /* {{{ */ php_session_remove_cookie(); /* remove already sent session ID cookie */ /* 'replace' must be 0 here, else a previous Set-Cookie header, probably sent with setcookie() will be replaced! */ - sapi_add_header_ex(estrndup(ZSTR_VAL(ncookie.s), ZSTR_LEN(ncookie.s)), ZSTR_LEN(ncookie.s), 0, 0); + zend_result result = sapi_add_header_ex(estrndup(ZSTR_VAL(ncookie.s), ZSTR_LEN(ncookie.s)), ZSTR_LEN(ncookie.s), 0, 0); smart_str_free(&ncookie); - return SUCCESS; + return result; } /* }}} */ diff --git a/ext/session/tests/session_start_cookie_header_rejected.phpt b/ext/session/tests/session_start_cookie_header_rejected.phpt new file mode 100644 index 000000000000..6c3e3b78a3b5 --- /dev/null +++ b/ext/session/tests/session_start_cookie_header_rejected.phpt @@ -0,0 +1,28 @@ +--TEST-- +session_start() when the SAPI rejects the session cookie header +--INI-- +session.save_handler=files +session.name=PHPSESSID +session.gc_probability=0 +--EXTENSIONS-- +session +--FILE-- + "/\r\nX-Injected: yes"]); + +var_dump(session_start()); +var_dump(session_status() === PHP_SESSION_NONE); + +?> +--EXPECT-- +handler: Header may not contain more than a single header, new line detected +bool(false) +bool(true)