Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion ext/date/php_date.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,6 @@ PHP_RINIT_FUNCTION(date)
efree(DATEG(timezone));
}
DATEG(timezone) = NULL;
DATEG(tzcache) = NULL;
DATEG(last_errors) = NULL;

return SUCCESS;
Expand Down Expand Up @@ -499,6 +498,11 @@ static timelib_tzinfo *php_date_parse_tzfile(const char *formal_tzname, const ti
timelib_tzinfo *tzi;
int dummy_error_code;

/* Startup memory is released before the first request, so don't cache it */
if (!EG(active)) {
return timelib_parse_tzfile(formal_tzname, tzdb, &dummy_error_code);
}

if(!DATEG(tzcache)) {
ALLOC_HASHTABLE(DATEG(tzcache));
zend_hash_init(DATEG(tzcache), 4, NULL, _php_date_tzinfo_dtor, 0);
Expand Down
23 changes: 23 additions & 0 deletions ext/date/tests/gh25388.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--TEST--
GH-25388 (Invalid access or leak of startup data for ext/date after early usage (php_log_err in minit+rinit))
--CREDITS--
bwoebi
--INI--
allow_url_include=1
log_errors=1
error_log={PWD}/gh25388.log
output_handler=inexistent
date.timezone=Europe/Berlin
--FILE--
<?php
echo date('e'), "\n";
?>
--CLEAN--
<?php
@unlink(__DIR__ . '/gh25388.log');
?>
--EXPECT--
Deprecated: Directive 'allow_url_include' is deprecated in Unknown on line 0

Warning: PHP Request Startup: function "inexistent" not found or invalid function name in Unknown on line 0
Europe/Berlin
Loading