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

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