summaryrefslogtreecommitdiff
path: root/libarchive/archive_read_support_format_iso9660.c
diff options
context:
space:
mode:
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>2012-01-19 02:31:31 -0500
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>2012-01-19 02:31:31 -0500
commit8007f5ddfa4b9604402e22c47e17b331ce153ab7 (patch)
treeca8286d74f8d440384e31251c498e3ea0f48af02 /libarchive/archive_read_support_format_iso9660.c
parent56418500132ba3a851981524211a5d93bc1d95a2 (diff)
downloadlibarchive-8007f5ddfa4b9604402e22c47e17b331ce153ab7.tar.gz
If the format of times in ISO images is invalid, reset the time to 0.
SVN-Revision: 4180
Diffstat (limited to 'libarchive/archive_read_support_format_iso9660.c')
-rw-r--r--libarchive/archive_read_support_format_iso9660.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/libarchive/archive_read_support_format_iso9660.c b/libarchive/archive_read_support_format_iso9660.c
index 0f0c3d66..942dfe25 100644
--- a/libarchive/archive_read_support_format_iso9660.c
+++ b/libarchive/archive_read_support_format_iso9660.c
@@ -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