]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
RAR reader: fix use after free
authorMartin Matuska <martin@matuska.org>
Sat, 11 May 2019 00:36:53 +0000 (02:36 +0200)
committerMartin Matuska <martin@matuska.org>
Sat, 11 May 2019 00:36:53 +0000 (02:36 +0200)
If read_data_compressed() returns ARCHIVE_FAILED, the caller is allowed
to continue with next archive headers. We need to set rar->start_new_table
after the ppmd7_context got freed, otherwise it won't be allocated again.

Reported by: OSS-Fuzz issue 2582

libarchive/archive_read_support_format_rar.c

index a8cc5c94d846839d89877b41e9527089e2aedd3c..49360876c2ac1189fcfabf1b0b7a2fb24b0aa0dd 100644 (file)
@@ -1024,8 +1024,10 @@ archive_read_format_rar_read_data(struct archive_read *a, const void **buff,
   case COMPRESS_METHOD_GOOD:
   case COMPRESS_METHOD_BEST:
     ret = read_data_compressed(a, buff, size, offset);
-    if (ret != ARCHIVE_OK && ret != ARCHIVE_WARN)
+    if (ret != ARCHIVE_OK && ret != ARCHIVE_WARN) {
       __archive_ppmd7_functions.Ppmd7_Free(&rar->ppmd7_context);
+      rar->start_new_table = 1;
+    }
     break;
 
   default: