1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 08:12:21 +01:00

Merge branch 'PHP-8.5'

* PHP-8.5:
  Fix GH-20771: Assertion failure when getUnicodeHost() returns empty string
  ext/session/mod_mm.c: add a few missing ZSTR macros
This commit is contained in:
Niels Dossche
2025-12-23 23:18:03 +01:00
3 changed files with 18 additions and 4 deletions

View File

@@ -264,7 +264,7 @@ static void ps_mm_destroy(ps_mm *data)
PHP_MINIT_FUNCTION(ps_mm)
{
size_t save_path_len = strlen(PS(save_path));
size_t save_path_len = ZSTR_LEN(PS(save_path));
size_t mod_name_len = strlen(sapi_module.name);
size_t euid_len;
char *ps_mm_path, euid[30];
@@ -284,8 +284,8 @@ PHP_MINIT_FUNCTION(ps_mm)
/* Directory + '/' + File + Module Name + Effective UID + \0 */
ps_mm_path = emalloc(save_path_len + 1 + (sizeof(PS_MM_FILE) - 1) + mod_name_len + euid_len + 1);
memcpy(ps_mm_path, PS(save_path), save_path_len);
if (save_path_len && PS(save_path)[save_path_len - 1] != DEFAULT_SLASH) {
memcpy(ps_mm_path, ZSTR_VAL(PS(save_path)), save_path_len);
if (save_path_len && ZSTR_VAL(PS(save_path))[save_path_len - 1] != DEFAULT_SLASH) {
ps_mm_path[save_path_len] = DEFAULT_SLASH;
save_path_len++;
}

View File

@@ -0,0 +1,14 @@
--TEST--
GH-20771 (Assertion failure when getUnicodeHost() returns empty string)
--EXTENSIONS--
uri
--FILE--
<?php
$url = Uri\WhatWg\Url::parse('test://');
var_dump($url->getUnicodeHost());
?>
--EXPECT--
string(0) ""

View File

@@ -365,7 +365,7 @@ static zend_result php_uri_parser_whatwg_host_read(void *uri, php_uri_component_
lxb_url_serialize_host_unicode(&lexbor_idna, &lexbor_uri->host, serialize_to_smart_str_callback, &host_str);
lxb_unicode_idna_clean(&lexbor_idna);
ZVAL_NEW_STR(retval, smart_str_extract(&host_str));
ZVAL_STR(retval, smart_str_extract(&host_str));
break;
}
case PHP_URI_COMPONENT_READ_MODE_NORMALIZED_ASCII: