From: Michihiro NAKAJIMA Date: Wed, 24 Feb 2010 06:26:14 +0000 (-0500) Subject: MSDOS-style date/time can handle only dates between 1980-01-10 and 2107-12-31. X-Git-Tag: v3.0.0a~1195 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=96b3cfd3fe092413846ae649e4a8f47c4dcb1b73;p=thirdparty%2Flibarchive.git MSDOS-style date/time can handle only dates between 1980-01-10 and 2107-12-31. SVN-Revision: 1970 --- diff --git a/libarchive/archive_write_set_format_zip.c b/libarchive/archive_write_set_format_zip.c index 620dc08b1..2bbabbaa1 100644 --- a/libarchive/archive_write_set_format_zip.c +++ b/libarchive/archive_write_set_format_zip.c @@ -611,6 +611,23 @@ dos_time(const time_t unix_time) * on two systems with different time zones. */ t = localtime(&unix_time); + /* MSDOS-style date/time is only between 1980-01-01 and 2107-12-31 */ + if (t->tm_year < 1980 - 1900) { + t->tm_year = 1980 - 1900; + t->tm_mon = 0; + t->tm_mday = 1; + t->tm_hour = 0; + t->tm_min = 0; + t->tm_sec = 0; + } + if (t->tm_year > 2107 - 1900) { + t->tm_year = 2107 - 1900; + t->tm_mon = 11; + t->tm_mday = 31; + t->tm_hour = 23; + t->tm_min = 59; + t->tm_sec = 59; + } dt = 0; dt += ((t->tm_year - 80) & 0x7f) << 9; dt += ((t->tm_mon + 1) & 0x0f) << 5;