From 271995df662b51b8fad5487b9ae1ac902c0a47ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Fri, 5 Sep 2025 14:08:14 +0200 Subject: [PATCH 1/3] uri: Show the uriparser runtime version in PHPInfo (#19718) --- ext/uri/php_uri.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ext/uri/php_uri.c b/ext/uri/php_uri.c index 0308c8625e0a8..613ca1386bc33 100644 --- a/ext/uri/php_uri.c +++ b/ext/uri/php_uri.c @@ -1061,8 +1061,9 @@ static PHP_MINIT_FUNCTION(uri) static PHP_MINFO_FUNCTION(uri) { php_info_print_table_start(); - php_info_print_table_row(2, "uri support", "active"); - php_info_print_table_row(2, "uriparser library version", URI_VER_ANSI); + php_info_print_table_row(2, "URI support", "active"); + php_info_print_table_row(2, "uriparser compiled version", URI_VER_ANSI); + php_info_print_table_row(2, "uriparser loaded version", uriBaseRuntimeVersionA()); php_info_print_table_end(); } From 66eb5e72a4bfb0f59ab3f0276c5bee4db3238b87 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Fri, 5 Sep 2025 15:46:35 +0200 Subject: [PATCH 2/3] allow to build with system liburiparser (#18886) --- ext/uri/config.m4 | 43 +++++++++++++++++++++++++++++++------------ ext/uri/php_uri.c | 5 +++++ 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/ext/uri/config.m4 b/ext/uri/config.m4 index 33d42c4497642..c8a179c96ef27 100644 --- a/ext/uri/config.m4 +++ b/ext/uri/config.m4 @@ -1,6 +1,13 @@ dnl Configure options dnl +PHP_ARG_WITH([external-uriparser], + [for external/system liburiparser], + [AS_HELP_STRING([--with-external-uriparser], + [Use external/system liburiparser])], + [no], + [no]) + PHP_INSTALL_HEADERS([ext/uri], m4_normalize([ php_uri.h php_uri_common.h @@ -9,20 +16,32 @@ PHP_INSTALL_HEADERS([ext/uri], m4_normalize([ uri_parser_php_parse_url.h ])) + AC_DEFINE([URI_ENABLE_ANSI], [1], [Define to 1 for enabling ANSI support of uriparser.]) AC_DEFINE([URI_NO_UNICODE], [1], [Define to 1 for disabling unicode support of uriparser.]) -URIPARSER_DIR="uriparser" -URIPARSER_SOURCES="$URIPARSER_DIR/src/UriCommon.c $URIPARSER_DIR/src/UriCompare.c $URIPARSER_DIR/src/UriCopy.c \ -$URIPARSER_DIR/src/UriEscape.c $URIPARSER_DIR/src/UriFile.c $URIPARSER_DIR/src/UriIp4.c $URIPARSER_DIR/src/UriIp4Base.c \ -$URIPARSER_DIR/src/UriMemory.c $URIPARSER_DIR/src/UriNormalize.c $URIPARSER_DIR/src/UriNormalizeBase.c \ -$URIPARSER_DIR/src/UriParse.c $URIPARSER_DIR/src/UriParseBase.c $URIPARSER_DIR/src/UriQuery.c \ -$URIPARSER_DIR/src/UriRecompose.c $URIPARSER_DIR/src/UriResolve.c $URIPARSER_DIR/src/UriSetFragment.c \ -$URIPARSER_DIR/src/UriSetHostAuto.c $URIPARSER_DIR/src/UriSetHostCommon.c $URIPARSER_DIR/src/UriSetHostIp4.c \ -$URIPARSER_DIR/src/UriSetHostIp6.c $URIPARSER_DIR/src/UriSetHostIpFuture.c $URIPARSER_DIR/src/UriSetHostRegName.c \ -$URIPARSER_DIR/src/UriSetPath.c $URIPARSER_DIR/src/UriSetPort.c $URIPARSER_DIR/src/UriSetQuery.c \ -$URIPARSER_DIR/src/UriSetScheme.c $URIPARSER_DIR/src/UriSetUserInfo.c $URIPARSER_DIR/src/UriShorten.c $URIPARSER_DIR/src/UriVersion.c" +if test "$PHP_EXTERNAL_URIPARSER" = "no"; then + URIPARSER_DIR="uriparser" + URIPARSER_SOURCES="$URIPARSER_DIR/src/UriCommon.c $URIPARSER_DIR/src/UriCompare.c $URIPARSER_DIR/src/UriCopy.c \ + $URIPARSER_DIR/src/UriEscape.c $URIPARSER_DIR/src/UriFile.c $URIPARSER_DIR/src/UriIp4.c $URIPARSER_DIR/src/UriIp4Base.c \ + $URIPARSER_DIR/src/UriMemory.c $URIPARSER_DIR/src/UriNormalize.c $URIPARSER_DIR/src/UriNormalizeBase.c \ + $URIPARSER_DIR/src/UriParse.c $URIPARSER_DIR/src/UriParseBase.c $URIPARSER_DIR/src/UriQuery.c \ + $URIPARSER_DIR/src/UriRecompose.c $URIPARSER_DIR/src/UriResolve.c $URIPARSER_DIR/src/UriSetFragment.c \ + $URIPARSER_DIR/src/UriSetHostAuto.c $URIPARSER_DIR/src/UriSetHostCommon.c $URIPARSER_DIR/src/UriSetHostIp4.c \ + $URIPARSER_DIR/src/UriSetHostIp6.c $URIPARSER_DIR/src/UriSetHostIpFuture.c $URIPARSER_DIR/src/UriSetHostRegName.c \ + $URIPARSER_DIR/src/UriSetPath.c $URIPARSER_DIR/src/UriSetPort.c $URIPARSER_DIR/src/UriSetQuery.c \ + $URIPARSER_DIR/src/UriSetScheme.c $URIPARSER_DIR/src/UriSetUserInfo.c $URIPARSER_DIR/src/UriShorten.c $URIPARSER_DIR/src/UriVersion.c" + URI_CFLAGS="-DURI_STATIC_BUILD" +else + PKG_CHECK_MODULES([LIBURIPARSER], [liburiparser >= 0.9.9]) + PHP_EVAL_LIBLINE([$LIBURIPARSER_LIBS], [URI_SHARED_LIBADD]) + PHP_EVAL_INCLINE([$LIBURIPARSER_CFLAGS]) +fi -PHP_NEW_EXTENSION(uri, [php_uri.c php_uri_common.c uri_parser_rfc3986.c uri_parser_whatwg.c uri_parser_php_parse_url.c $URIPARSER_SOURCES], [no],,[-I$ext_srcdir/$URIPARSER_DIR/include -DURI_STATIC_BUILD -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1]) +PHP_NEW_EXTENSION(uri, [php_uri.c php_uri_common.c uri_parser_rfc3986.c uri_parser_whatwg.c uri_parser_php_parse_url.c $URIPARSER_SOURCES], [no],,[$URI_CFLAGS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1]) PHP_ADD_EXTENSION_DEP(uri, lexbor) -PHP_ADD_BUILD_DIR($ext_builddir/$URIPARSER_DIR/src $ext_builddir/$URIPARSER_DIR/include) + +if test "$PHP_EXTERNAL_URIPARSER" = "no"; then + PHP_ADD_BUILD_DIR($ext_builddir/$URIPARSER_DIR/src $ext_builddir/$URIPARSER_DIR/include) + PHP_ADD_INCLUDE([$ext_srcdir/$URIPARSER_DIR/include]) +fi diff --git a/ext/uri/php_uri.c b/ext/uri/php_uri.c index 613ca1386bc33..a0e264f04f3e2 100644 --- a/ext/uri/php_uri.c +++ b/ext/uri/php_uri.c @@ -30,6 +30,7 @@ #include "uri_parser_rfc3986.h" #include "uri_parser_php_parse_url.h" #include "php_uri_arginfo.h" +#include "uriparser/UriBase.h" zend_class_entry *uri_rfc3986_uri_ce; zend_object_handlers uri_rfc3986_uri_object_handlers; @@ -1062,8 +1063,12 @@ static PHP_MINFO_FUNCTION(uri) { php_info_print_table_start(); php_info_print_table_row(2, "URI support", "active"); +#ifdef URI_STATIC_BUILD + php_info_print_table_row(2, "uriparser bundled version", URI_VER_ANSI); +#else php_info_print_table_row(2, "uriparser compiled version", URI_VER_ANSI); php_info_print_table_row(2, "uriparser loaded version", uriBaseRuntimeVersionA()); +#endif php_info_print_table_end(); } From 216e87ad7e33fda75f33e31c36a30b04b90e4696 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Thu, 4 Sep 2025 22:46:07 +0200 Subject: [PATCH 3/3] Fix memory leak in zip when encountering empty glob result The case of returning 0 is inconsistent in when it returns an empty array, furthermore the caller already returns an empty array. Because the caller overwrites the return value in these cases, it can cause a memory leak. This is easier to trigger on master in some cases as different code paths are taken with the new bundled glob. On some platforms it is also triggerable on 8.3. Closes GH-19715. --- NEWS | 3 +++ ext/zip/php_zip.c | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index ed92a4588dea6..80d74f373a179 100644 --- a/NEWS +++ b/NEWS @@ -52,6 +52,9 @@ PHP NEWS deprecation and TidyInternalCategory being available later than tidyOptGetCategory. (arjendekorte) +- Zip: + . Fix memory leak in zip when encountering empty glob result. (nielsdos) + 28 Aug 2025, PHP 8.3.25 - Core: diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index 3710b304c3515..9f1d296336e09 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -668,7 +668,6 @@ int php_zip_glob(char *pattern, int pattern_len, zend_long flags, zval *return_v can be used for simple glob() calls without further error checking. */ - array_init(return_value); return 0; } #endif @@ -677,7 +676,6 @@ int php_zip_glob(char *pattern, int pattern_len, zend_long flags, zval *return_v /* now catch the FreeBSD style of "no matches" */ if (!globbuf.gl_pathc || !globbuf.gl_pathv) { - array_init(return_value); return 0; }