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

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