]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
If the format of times in ISO images is invalid, reset the time to 0.
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Thu, 19 Jan 2012 07:31:31 +0000 (02:31 -0500)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Thu, 19 Jan 2012 07:31:31 +0000 (02:31 -0500)
SVN-Revision: 4180

libarchive/archive_read_support_format_iso9660.c

index 0f0c3d66f93a4f543bcd8b93b21217ae35334b97..942dfe253913bab011b4d341e4b0116f426d8670 100644 (file)
@@ -3085,6 +3085,8 @@ isodate7(const unsigned char *v)
 {
        struct tm tm;
        int offset;
+       time_t t;
+
        memset(&tm, 0, sizeof(tm));
        tm.tm_year = v[0];
        tm.tm_mon = v[1] - 1;
@@ -3098,7 +3100,10 @@ isodate7(const unsigned char *v)
                tm.tm_hour -= offset / 4;
                tm.tm_min -= (offset % 4) * 15;
        }
-       return (time_from_tm(&tm));
+       t = time_from_tm(&tm);
+       if (t == (time_t)-1)
+               return ((time_t)0);
+       return (t);
 }
 
 static time_t
@@ -3106,6 +3111,8 @@ isodate17(const unsigned char *v)
 {
        struct tm tm;
        int offset;
+       time_t t;
+
        memset(&tm, 0, sizeof(tm));
        tm.tm_year = (v[0] - '0') * 1000 + (v[1] - '0') * 100
            + (v[2] - '0') * 10 + (v[3] - '0')
@@ -3121,7 +3128,10 @@ isodate17(const unsigned char *v)
                tm.tm_hour -= offset / 4;
                tm.tm_min -= (offset % 4) * 15;
        }
-       return (time_from_tm(&tm));
+       t = time_from_tm(&tm);
+       if (t == (time_t)-1)
+               return ((time_t)0);
+       return (t);
 }
 
 static time_t
@@ -3135,7 +3145,8 @@ time_from_tm(struct tm *t)
 #else
        /* Else use direct calculation using POSIX assumptions. */
        /* First, fix up tm_yday based on the year/month/day. */
-       mktime(t);
+       if (mktime(t) == (time_t)-1)
+               return ((time_t)-1);
        /* Then we can compute timegm() from first principles. */
        return (t->tm_sec + t->tm_min * 60 + t->tm_hour * 3600
            + t->tm_yday * 86400 + (t->tm_year - 70) * 31536000