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

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