From 6079dbbd29a3288156a262a76239567f89c6814c Mon Sep 17 00:00:00 2001 From: Maximilian Mader Date: Sat, 3 Aug 2013 23:56:13 +0200 Subject: [PATCH] Don't allow dates prior to 1980-01-01 See WoltLab/WCF#1443 Zip doesn't support dates prior to `1980-01-01 00:00 UTC` --- .../install/files/lib/system/io/ZipWriter.class.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/lib/system/io/ZipWriter.class.php b/wcfsetup/install/files/lib/system/io/ZipWriter.class.php index 39dc4c14d2..08c2e1d9e2 100644 --- a/wcfsetup/install/files/lib/system/io/ZipWriter.class.php +++ b/wcfsetup/install/files/lib/system/io/ZipWriter.class.php @@ -2,6 +2,7 @@ namespace wcf\system\io; use wcf\util\FileUtil; use wcf\util\StringUtil; +use wcf\system\exception\SystemException; /** * Creates a Zip file archive. @@ -81,9 +82,14 @@ class ZipWriter { * * @param string $data content of the file * @param string $name filename - * @param integer $date file creation time as unix timestamp + * @param integer $date file creation time as unix timestamp, must at least be 315532800 (1980-01-01 00:00 UTC) */ - public function addFile($data, $name, $date = 0) { + public function addFile($data, $name, $date = TIME_NOW) { + // 315532800 is the same as strtotime('1980-01-01 00:00 UTC') + if ($date < 315532800) { + throw new SystemException('Unsupported date, must be at least 315532800 (1980-01-01 00:00 UTC)'); + } + // replace backward slashes with forward slashes in the filename $name = StringUtil::replace("\\", "/", $name); -- 2.20.1