From 44c8b7414ce96038017edc2fd827f8250669a62a Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Wed, 3 Jul 2019 09:59:17 +0200 Subject: Fix #78241: touch() does not handle dates after 2038 in PHP 64-bit `time_t` defaults to `_time64` (which is 64bit signed) even on x86, but `Int32x32To64()` truncates it to signed 32bit. We replace the macro with the "manual" calculation. --- NEWS | 3 +++ TSRM/tsrm_win32.c | 2 +- ext/standard/tests/file/bug78241.phpt | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 ext/standard/tests/file/bug78241.phpt diff --git a/NEWS b/NEWS index 078d61c1eb..4c05f42773 100644 --- a/NEWS +++ b/NEWS @@ -21,6 +21,9 @@ PHP NEWS . Fixed #78189 (file cache strips last character of uname hash). (cmb) . Fixed #78202 (Opcache stats for cache hits are capped at 32bit NUM). (cmb) +- Standard: + . Fixed #78241 (touch() does not handle dates after 2038 in PHP 64-bit). (cmb) + 27 Jun 2019, PHP 7.2.20 - Core: diff --git a/TSRM/tsrm_win32.c b/TSRM/tsrm_win32.c index ca121de057..34b0676461 100644 --- a/TSRM/tsrm_win32.c +++ b/TSRM/tsrm_win32.c @@ -804,7 +804,7 @@ static zend_always_inline void UnixTimeToFileTime(time_t t, LPFILETIME pft) /* { // Note that LONGLONG is a 64-bit value LONGLONG ll; - ll = Int32x32To64(t, 10000000) + 116444736000000000; + ll = t * 10000000 + 116444736000000000; pft->dwLowDateTime = (DWORD)ll; pft->dwHighDateTime = ll >> 32; } diff --git a/ext/standard/tests/file/bug78241.phpt b/ext/standard/tests/file/bug78241.phpt new file mode 100644 index 0000000000..99fed8a5a3 --- /dev/null +++ b/ext/standard/tests/file/bug78241.phpt @@ -0,0 +1,33 @@ +--TEST-- +Bug #78241 (touch() does not handle dates after 2038 in PHP 64-bit) +--SKIPIF-- + +--INI-- +date.timezone=UTC +--FILE-- + +--EXPECT-- +Date: Thu, 01 Jan 2037 01:01:01 +File: Thu, 01 Jan 2037 01:01:01 + +Date: Fri, 01 Jan 2038 01:01:01 +File: Fri, 01 Jan 2038 01:01:01 + +Date: Sat, 01 Jan 2039 01:01:01 +File: Sat, 01 Jan 2039 01:01:01 + +Date: Sun, 01 Jan 2040 01:01:01 +File: Sun, 01 Jan 2040 01:01:01 -- cgit v1.2.1