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