From cb33386482654a1a3008ee8fa48147167d5ec276 Mon Sep 17 00:00:00 2001 From: arshidkv12 Date: Mon, 2 Nov 2026 20:34:15 +0530 Subject: [PATCH 1/2] ext/date: Fix strtotime() handling of embedded NUL bytes --- ext/date/php_date.c | 4 ++++ ext/date/tests/strtotime_nul_byte.phpt | 15 +++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 ext/date/tests/strtotime_nul_byte.phpt diff --git a/ext/date/php_date.c b/ext/date/php_date.c index d97dc0825937..f4a9e74a9c85 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -1107,6 +1107,10 @@ PHP_FUNCTION(strtotime) RETURN_FALSE; } + if (memchr(ZSTR_VAL(times), '\0', ZSTR_LEN(times)) != NULL) { + RETURN_FALSE; + } + tzi = get_timezone_info(); if (!tzi) { return; diff --git a/ext/date/tests/strtotime_nul_byte.phpt b/ext/date/tests/strtotime_nul_byte.phpt new file mode 100644 index 000000000000..ae3129c79469 --- /dev/null +++ b/ext/date/tests/strtotime_nul_byte.phpt @@ -0,0 +1,15 @@ +--TEST-- +strtotime() rejects strings containing NUL bytes +--FILE-- + +--EXPECT-- +bool(false) +bool(false) +bool(false) +bool(false) From c120a8ec4263619bfcc83ae768d87ff146b86bb4 Mon Sep 17 00:00:00 2001 From: arshidkv12 Date: Mon, 2 Nov 2026 20:41:35 +0530 Subject: [PATCH 2/2] ext/date: Fix strtotime() handling of embedded NUL bytes --- ext/date/tests/strtotime_nul_byte.phpt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ext/date/tests/strtotime_nul_byte.phpt b/ext/date/tests/strtotime_nul_byte.phpt index ae3129c79469..615450b3df61 100644 --- a/ext/date/tests/strtotime_nul_byte.phpt +++ b/ext/date/tests/strtotime_nul_byte.phpt @@ -1,5 +1,7 @@ --TEST-- strtotime() rejects strings containing NUL bytes +--CREDITS-- +HackingRepo (relunsec@insitetech.jp) --FILE--