Blame SOURCES/libarchive-3.1.2-CVE-2015-8931.patch

995285
From 11f6da24b13840397fee87445859d7f2a2ac02f8 Mon Sep 17 00:00:00 2001
995285
From: Tim Kientzle <kientzle@acm.org>
995285
Date: Sat, 16 May 2015 12:16:28 -0700
995285
Subject: [PATCH] This is a combination of 2 commits. == The first commit's
995285
 message is: ==
995285
995285
Issue #539:  Try a different way to compute max/min time_t values.
995285
995285
== This is the 2nd commit message: ==
995285
995285
Don't try to be smart about probing the min/max tim_t values.
995285
Just assume that a signed time_t is really a 64-bit or 32-bit integer.
995285
---
995285
 libarchive/archive_read_support_format_mtree.c | 47 ++++++++++++++------------
995285
 1 file changed, 25 insertions(+), 22 deletions(-)
995285
995285
diff --git a/libarchive/archive_read_support_format_mtree.c b/libarchive/archive_read_support_format_mtree.c
995285
index 64d5e67..3abe198 100644
995285
--- a/libarchive/archive_read_support_format_mtree.c
995285
+++ b/libarchive/archive_read_support_format_mtree.c
995285
@@ -139,16 +139,22 @@ get_time_t_max(void)
995285
 #if defined(TIME_T_MAX)
995285
 	return TIME_T_MAX;
995285
 #else
995285
-	static time_t t;
995285
-	time_t a;
995285
-	if (t == 0) {
995285
-		a = 1;
995285
-		while (a > t) {
995285
-			t = a;
995285
-			a = a * 2 + 1;
995285
+	/* ISO C allows time_t to be a floating-point type,
995285
+	   but POSIX requires an integer type.  The following
995285
+	   should work on any system that follows the POSIX
995285
+	   conventions. */
995285
+	if (((time_t)0) < ((time_t)-1)) {
995285
+		/* Time_t is unsigned */
995285
+		return (~(time_t)0);
995285
+	} else {
995285
+		/* Time_t is signed. */
995285
+		/* Assume it's the same as int64_t or int32_t */
995285
+		if (sizeof(time_t) == sizeof(int64_t)) {
995285
+			return (time_t)INT64_MAX;
995285
+		} else {
995285
+			return (time_t)INT32_MAX;
995285
 		}
995285
 	}
995285
-	return t;
995285
 #endif
995285
 }
995285
 
995285
@@ -158,20 +164,17 @@ get_time_t_min(void)
995285
 #if defined(TIME_T_MIN)
995285
 	return TIME_T_MIN;
995285
 #else
995285
-	/* 't' will hold the minimum value, which will be zero (if
995285
-	 * time_t is unsigned) or -2^n (if time_t is signed). */
995285
-	static int computed;
995285
-	static time_t t;
995285
-	time_t a;
995285
-	if (computed == 0) {
995285
-		a = (time_t)-1;
995285
-		while (a < t) {
995285
-			t = a;
995285
-			a = a * 2;
995285
-		}			
995285
-		computed = 1;
995285
+	if (((time_t)0) < ((time_t)-1)) {
995285
+		/* Time_t is unsigned */
995285
+		return (time_t)0;
995285
+	} else {
995285
+		/* Time_t is signed. */
995285
+		if (sizeof(time_t) == sizeof(int64_t)) {
995285
+			return (time_t)INT64_MIN;
995285
+		} else {
995285
+			return (time_t)INT32_MIN;
995285
+		}
995285
 	}
995285
-	return t;
995285
 #endif
995285
 }
995285
 
995285
@@ -1562,7 +1565,7 @@ parse_keyword(struct archive_read *a, struct mtree *mtree,
995285
 			int64_t m;
995285
 			int64_t my_time_t_max = get_time_t_max();
995285
 			int64_t my_time_t_min = get_time_t_min();
995285
-			long ns;
995285
+			long ns = 0;
995285
 
995285
 			*parsed_kws |= MTREE_HAS_MTIME;
995285
 			m = mtree_atol10(&val;;
995285
-- 
995285
2.7.4
995285