Commit cb20015e045 for php
commit cb20015e045508ed6642ab7d72858270f9224d64
Author: Ilija Tovilo <ilija.tovilo@me.com>
Date: Sun Nov 15 15:25:20 2026 +0100
Fix GHSA-gr4f-wgx5-jpfv: DATEG(tzcache) use-after-free
diff --git a/ext/date/tests/GHSA-gr4f-wgx5-jpfv.phpt b/ext/date/tests/GHSA-gr4f-wgx5-jpfv.phpt
new file mode 100644
index 00000000000..bb81c93ddb2
--- /dev/null
+++ b/ext/date/tests/GHSA-gr4f-wgx5-jpfv.phpt
@@ -0,0 +1,22 @@
+--TEST--
+GHSA-gr4f-wgx5-jpfv: DATEG(tzcache) use-after-free
+--CREDITS--
+Sebastian Bergmann
+--CGI--
+--ENV--
+QUERY_STRING=a=1&b=2
+--EXTENSIONS--
+session
+zend_test
+--INI--
+error_log="{TMP}/GHSA-gr4f-wgx5-jpfv.log"
+log_errors=1
+max_input_vars=1
+zend_test.warn_on_startup=1
+--FILE--
+<?php
+echo "Hello world\n";
+?>
+--EXPECTF--
+Warning: PHP Request Startup: Input variables exceeded 1. To increase the limit change max_input_vars in php.ini. in Unknown on line 0
+Hello world%r(?:\n\nWarning: Test startup warning from zend_test in Unknown on line 0)?%r
diff --git a/ext/zend_test/php_test.h b/ext/zend_test/php_test.h
index 89570d1155c..e9e2ea5bde2 100644
--- a/ext/zend_test/php_test.h
+++ b/ext/zend_test/php_test.h
@@ -54,6 +54,7 @@ ZEND_BEGIN_MODULE_GLOBALS(zend_test)
int replace_zend_execute_ex;
int register_passes;
bool print_stderr_mshutdown;
+ bool warn_on_startup;
zend_long limit_copy_file_range;
int observe_opline_in_zendmm;
zend_mm_heap* zend_orig_heap;
diff --git a/ext/zend_test/test.c b/ext/zend_test/test.c
index a6cba8ddf40..bea3fe223f7 100644
--- a/ext/zend_test/test.c
+++ b/ext/zend_test/test.c
@@ -614,6 +614,17 @@ static PHP_INI_MH(OnUpdateZendTestObserveOplineInZendMM)
return OnUpdateBool(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
}
+static PHP_INI_MH(OnUpdateZendTestWarnOnStartup)
+{
+ zend_result result = OnUpdateBool(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
+ if (result == SUCCESS) {
+ if (*(bool *)ZEND_INI_GET_ADDR()) {
+ zend_error(E_WARNING, "Test startup warning from zend_test");
+ }
+ }
+ return result;
+}
+
static ZEND_FUNCTION(zend_test_is_pcre_bundled)
{
ZEND_PARSE_PARAMETERS_NONE();
@@ -1078,6 +1089,7 @@ PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("zend_test.str_test", "", PHP_INI_ALL, OnUpdateStr, str_test, zend_zend_test_globals, zend_test_globals)
STD_PHP_INI_ENTRY("zend_test.not_empty_str_test", "val", PHP_INI_ALL, OnUpdateStrNotEmpty, not_empty_str_test, zend_zend_test_globals, zend_test_globals)
STD_PHP_INI_BOOLEAN("zend_test.observe_opline_in_zendmm", "0", PHP_INI_ALL, OnUpdateZendTestObserveOplineInZendMM, observe_opline_in_zendmm, zend_zend_test_globals, zend_test_globals)
+ STD_PHP_INI_BOOLEAN("zend_test.warn_on_startup", "0", PHP_INI_SYSTEM, OnUpdateZendTestWarnOnStartup, warn_on_startup, zend_zend_test_globals, zend_test_globals)
PHP_INI_END()
void (*old_zend_execute_ex)(zend_execute_data *execute_data);
diff --git a/main/main.c b/main/main.c
index 4ff0c034f1b..95da1bcf547 100644
--- a/main/main.c
+++ b/main/main.c
@@ -858,15 +858,7 @@ PHPAPI ZEND_COLD void php_log_err_with_severity(const char *log_message, int sys
zend_string *error_time_str;
time(&error_time);
-#ifdef ZTS
- if (!php_during_module_startup()) {
- error_time_str = php_format_date("d-M-Y H:i:s e", 13, error_time, 1);
- } else {
- error_time_str = php_format_date("d-M-Y H:i:s e", 13, error_time, 0);
- }
-#else
- error_time_str = php_format_date("d-M-Y H:i:s e", 13, error_time, 1);
-#endif
+ error_time_str = php_format_date("d-M-Y H:i:s e", 13, error_time, PG(modules_activated) && EG(active));
len = spprintf(&tmp, 0, "[%s] %s%s", ZSTR_VAL(error_time_str), log_message, PHP_EOL);
#ifdef PHP_WIN32
php_flock(fd, LOCK_EX);