|
|
58251f |
From aab73938f8914f0def6cdd5d5be3f142ae7c77f6 Mon Sep 17 00:00:00 2001
|
|
|
58251f |
From: Tim Kientzle <kientzle@acm.org>
|
|
|
58251f |
Date: Tue, 3 Mar 2015 20:17:37 -0800
|
|
|
58251f |
Subject: [PATCH] Issue 410: Segfault on invalid rar archive
|
|
|
58251f |
|
|
|
58251f |
Libarchive's API passes a void ** which is set by the format
|
|
|
58251f |
to the address of the entry data that was just read.
|
|
|
58251f |
|
|
|
58251f |
In one particular case, the RAR decompression logic uses a
|
|
|
58251f |
non-NULL value here to indicate that the internal 128k decompression
|
|
|
58251f |
buffer has been filled. But the RAR code took no steps to ensure
|
|
|
58251f |
that the value was set NULL on entry. As a result, a crafted RAR
|
|
|
58251f |
file can trick libarchive into returning to the caller a 128k block
|
|
|
58251f |
of data starting at whatever value was previously in the caller's
|
|
|
58251f |
variable.
|
|
|
58251f |
|
|
|
58251f |
The fix is simply to set *buff = NULL on entry to the RAR
|
|
|
58251f |
decompression logic.
|
|
|
58251f |
---
|
|
|
58251f |
libarchive/archive_read_support_format_rar.c | 2 +-
|
|
|
58251f |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
58251f |
|
|
|
58251f |
diff --git a/libarchive/archive_read_support_format_rar.c b/libarchive/archive_read_support_format_rar.c
|
|
|
58251f |
index 3e7412f..ee8ce53 100644
|
|
|
58251f |
--- a/libarchive/archive_read_support_format_rar.c
|
|
|
58251f |
+++ b/libarchive/archive_read_support_format_rar.c
|
|
|
58251f |
@@ -1002,8 +1002,8 @@ archive_read_format_rar_read_data(struct archive_read *a, const void **buff,
|
|
|
58251f |
rar->bytes_unconsumed = 0;
|
|
|
58251f |
}
|
|
|
58251f |
|
|
|
58251f |
+ *buff = NULL;
|
|
|
58251f |
if (rar->entry_eof || rar->offset_seek >= rar->unp_size) {
|
|
|
58251f |
- *buff = NULL;
|
|
|
58251f |
*size = 0;
|
|
|
58251f |
*offset = rar->offset;
|
|
|
58251f |
if (*offset < rar->unp_size)
|
|
|
58251f |
--
|
|
|
58251f |
2.7.4
|
|
|
58251f |
|