]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Issue 719: Fix for TALOS-CAN-154
authorTim Kientzle <kientzle@acm.org>
Sun, 19 Jun 2016 21:21:42 +0000 (14:21 -0700)
committerTim Kientzle <kientzle@acm.org>
Sun, 19 Jun 2016 21:21:42 +0000 (14:21 -0700)
A RAR file with an invalid zero dictionary size was not being
rejected, leading to a zero-sized allocation for the dictionary
storage which was then overwritten during the dictionary initialization.

Thanks to the Open Source and Threat Intelligence project at Cisco for
reporting this.

libarchive/archive_read_support_format_rar.c

index 6450aac82785b1c2cb48fd7b2d1d53530d08032b..6c49f1a1501c9d341dd7ea2f843d3016a1ecfc7b 100644 (file)
@@ -2127,6 +2127,12 @@ parse_codes(struct archive_read *a)
       rar->range_dec.Stream = &rar->bytein;
       __archive_ppmd7_functions.Ppmd7_Construct(&rar->ppmd7_context);
 
+      if (rar->dictionary_size == 0) {
+             archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+                          "Invalid zero dictionary size");
+             return (ARCHIVE_FATAL);
+      }
+
       if (!__archive_ppmd7_functions.Ppmd7_Alloc(&rar->ppmd7_context,
         rar->dictionary_size, &g_szalloc))
       {