[php-src] master: Merge branch 'PHP-8.2' into PHP-8.3
| From: | Niels Dossche | Date: | Sat, 06 Apr 2024 11:45:40 +0000 |
| Subject: | [php-src] master: Merge branch 'PHP-8.2' into PHP-8.3 | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-127952@lists.php.net to get a copy of this message | ||
Author: Niels Dossche (nielsdos)
Date: 2024-04-06T13:45:00+02:00
Commit: https://github.com/php/php-src/commit/eb244fcb49381e4340bd211d48e1577db5f3755a
Raw diff: https://github.com/php/php-src/commit/eb244fcb49381e4340bd211d48e1577db5f3755a.diff
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
[ci skip] NEWS
Fix GH-13891: memleak and segfault when using ini_set with session.trans_sid_hosts (#13892)
Changed paths:
A ext/session/tests/gh13891.phpt
M NEWS
M ext/standard/url_scanner_ex.re
Diff:
diff --git a/NEWS b/NEWS
index 421d706cf33e4..aea4354cfcf80 100644
--- a/NEWS
+++ b/NEWS
@@ -34,6 +34,8 @@ PHP NEWS
- Session:
. Fixed bug GH-13856 (Member access within null pointer of type 'ps_files' in
ext/session/mod_files.c). (nielsdos)
+ . Fixed bug GH-13891 (memleak and segfault when using ini_set with
+ session.trans_sid_hosts). (nielsdos, kamil-tekiela).
- Streams:
. Fixed bug GH-13264 (Part 1 - Memory leak on stream filter failure).
diff --git a/ext/session/tests/gh13891.phpt b/ext/session/tests/gh13891.phpt
new file mode 100644
index 0000000000000..7df9bffa770bc
--- /dev/null
+++ b/ext/session/tests/gh13891.phpt
@@ -0,0 +1,17 @@
+--TEST--
+GH-13891 (memleak and segfault when using ini_set with session.trans_sid_hosts)
+--INI--
+session.use_cookies=0
+session.use_only_cookies=0
+session.use_trans_sid=1
+session.trans_sid_hosts=php.net
+--EXTENSIONS--
+session
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--FILE--
+<?php
+// We *must* set it here because the bug only triggers on a runtime edit
+ini_set('session.trans_sid_hosts','php.net');
+?>
+--EXPECT--
diff --git a/ext/standard/url_scanner_ex.re b/ext/standard/url_scanner_ex.re
index 8e5b43467fc88..a4a48b6bf60ee 100644
--- a/ext/standard/url_scanner_ex.re
+++ b/ext/standard/url_scanner_ex.re
@@ -138,9 +138,10 @@ static int php_ini_on_update_hosts(zend_ini_entry *entry, zend_string
*new_value
}
keylen = q - key;
if (keylen > 0) {
- tmp_key = zend_string_init(key, keylen, 0);
+ /* Note: the hash table is persistently allocated, so the strings must be too! */
+ tmp_key = zend_string_init(key, keylen, true);
zend_hash_add_empty_element(hosts, tmp_key);
- zend_string_release_ex(tmp_key, 0);
+ zend_string_release_ex(tmp_key, true);
}
}
efree(tmp);