Blame SOURCES/libarchive-3.3.2-CVE-2018-1000877.patch

58251f
From 88311f46cdfc719d26bb99d3b47944eb92ceae02 Mon Sep 17 00:00:00 2001
58251f
From: Ondrej Dubaj <odubaj@redhat.com>
58251f
Date: Tue, 30 Apr 2019 11:50:33 +0200
58251f
Subject: [PATCH] Avoid a double-free when a window size of 0 is specified
58251f
58251f
new_size can be 0 with a malicious or corrupted RAR archive.
58251f
58251f
realloc(area, 0) is equivalent to free(area), so the region would
58251f
be free()d here and the free()d again in the cleanup function.
58251f
58251f
Found with a setup running AFL, afl-rb, and qsym.
58251f
---
58251f
 libarchive/archive_read_support_format_rar.c | 5 +++++
58251f
 1 file changed, 5 insertions(+)
58251f
58251f
diff --git a/libarchive/archive_read_support_format_rar.c b/libarchive/archive_read_support_format_rar.c
58251f
index c4a8278..3f88eef 100644
58251f
--- a/libarchive/archive_read_support_format_rar.c
58251f
+++ b/libarchive/archive_read_support_format_rar.c
58251f
@@ -2317,6 +2317,11 @@ parse_codes(struct archive_read *a)
58251f
       new_size = DICTIONARY_MAX_SIZE;
58251f
     else
58251f
       new_size = rar_fls((unsigned int)rar->unp_size) << 1;
58251f
+    if (new_size == 0) {
58251f
+    archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
58251f
+                      "Zero window size is invalid.");
58251f
+    return (ARCHIVE_FATAL);
58251f
+    }
58251f
     new_window = realloc(rar->lzss.window, new_size);
58251f
     if (new_window == NULL) {
58251f
       archive_set_error(&a->archive, ENOMEM,
58251f
-- 
58251f
2.17.1
58251f