]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
MSDOS-style date/time can handle only dates between 1980-01-10 and 2107-12-31.
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Wed, 24 Feb 2010 06:26:14 +0000 (01:26 -0500)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Wed, 24 Feb 2010 06:26:14 +0000 (01:26 -0500)
SVN-Revision: 1970

libarchive/archive_write_set_format_zip.c

index 620dc08b173d6d685d613817879972710065d8da..2bbabbaa12814e4ec5f04f6b1f9b013d32ab1f85 100644 (file)
@@ -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;