summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2019-07-03 10:00:05 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2019-07-03 10:02:22 +0200
commit5e5b7cb4d4fe72052a9408dccfee7d41063a3586 (patch)
tree22aab7e3e59889036af385a8c1dbe1dd8f365f97
parent9ad09ce905f97f0cb8b1ca4dc9589e4da9d09a70 (diff)
parent44c8b7414ce96038017edc2fd827f8250669a62a (diff)
downloadphp-git-5e5b7cb4d4fe72052a9408dccfee7d41063a3586.tar.gz
Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2: Fix #78241: touch() does not handle dates after 2038 in PHP 64-bit
-rw-r--r--NEWS3
-rw-r--r--TSRM/tsrm_win32.c2
-rw-r--r--ext/standard/tests/file/bug78241.phpt33
3 files changed, 37 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 5d0a417d7e..cc6a9dff91 100644
--- a/NEWS
+++ b/NEWS
@@ -21,6 +21,9 @@ PHP NEWS
. Fixed #78192 (SegFault when reuse statement after schema has changed).
(Vincent Quatrevieux)
+- Standard:
+ . Fixed #78241 (touch() does not handle dates after 2038 in PHP 64-bit). (cmb)
+
04 Jul 2019, PHP 7.3.7
- Core:
diff --git a/TSRM/tsrm_win32.c b/TSRM/tsrm_win32.c
index a7956caf90..5f0ebba5ae 100644
--- a/TSRM/tsrm_win32.c
+++ b/TSRM/tsrm_win32.c
@@ -770,7 +770,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--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') die('skip this test is for Windows platforms only');
+if (PHP_INT_SIZE != 8) die('skip this test is for 64bit platforms only');
+?>
+--INI--
+date.timezone=UTC
+--FILE--
+<?php
+$filename = __DIR__ . '/bug78241.txt';
+for ($i = 2037; $i <= 2040; $i++) {
+ $t = mktime(1, 1 , 1, 1, 1, $i);
+ echo 'Date: '.date('D, d M Y H:i:s', $t), PHP_EOL;
+ touch($filename, $t);
+ clearstatcache(true, $filename);
+ $file = filemtime($filename);
+ echo 'File: '.date('D, d M Y H:i:s', $file), PHP_EOL, PHP_EOL;
+}
+?>
+--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