Blame SOURCES/libarchive-3.1.2-CVE-2019-1000020.patch

58251f
From 8312eaa576014cd9b965012af51bc1f967b12423 Mon Sep 17 00:00:00 2001
58251f
From: Daniel Axtens <dja@axtens.net>
58251f
Date: Tue, 1 Jan 2019 17:10:49 +1100
58251f
Subject: [PATCH 1/2] iso9660: Fail when expected Rockridge extensions is
58251f
 missing
58251f
58251f
A corrupted or malicious ISO9660 image can cause read_CE() to loop
58251f
forever.
58251f
58251f
read_CE() calls parse_rockridge(), expecting a Rockridge extension
58251f
to be read. However, parse_rockridge() is structured as a while
58251f
loop starting with a sanity check, and if the sanity check fails
58251f
before the loop has run, the function returns ARCHIVE_OK without
58251f
advancing the position in the file. This causes read_CE() to retry
58251f
indefinitely.
58251f
58251f
Make parse_rockridge() return ARCHIVE_WARN if it didn't read an
58251f
extension. As someone with no real knowledge of the format, this
58251f
seems more apt than ARCHIVE_FATAL, but both the call-sites escalate
58251f
it to a fatal error immediately anyway.
58251f
58251f
Found with a combination of AFL, afl-rb (FairFuzz) and qsym.
58251f
---
58251f
 libarchive/archive_read_support_format_iso9660.c | 11 ++++++++++-
58251f
 1 file changed, 10 insertions(+), 1 deletion(-)
58251f
58251f
diff --git a/libarchive/archive_read_support_format_iso9660.c b/libarchive/archive_read_support_format_iso9660.c
58251f
index 28acfefb..bad8f1df 100644
58251f
--- a/libarchive/archive_read_support_format_iso9660.c
58251f
+++ b/libarchive/archive_read_support_format_iso9660.c
58251f
@@ -2102,6 +2102,7 @@ parse_rockridge(struct archive_read *a, struct file_info *file,
58251f
     const unsigned char *p, const unsigned char *end)
58251f
 {
58251f
 	struct iso9660 *iso9660;
58251f
+	int entry_seen = 0;
58251f
 
58251f
 	iso9660 = (struct iso9660 *)(a->format->data);
58251f
 
58251f
@@ -2257,8 +2258,16 @@ parse_rockridge(struct archive_read *a, struct file_info *file,
58251f
 		}
58251f
 
58251f
 		p += p[2];
58251f
+		entry_seen = 1;
58251f
+	}
58251f
+
58251f
+	if (entry_seen)
58251f
+		return (ARCHIVE_OK);
58251f
+	else {
58251f
+		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
58251f
+				  "Tried to parse Rockridge extensions, but none found");
58251f
+		return (ARCHIVE_WARN);
58251f
 	}
58251f
-	return (ARCHIVE_OK);
58251f
 }
58251f
 
58251f
 static int
58251f
-- 
58251f
2.20.1
58251f