]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Make sure sizes for RAR files are valid.
authorAndres Mejia <amejia004@gmail.com>
Fri, 22 Jul 2011 21:29:23 +0000 (17:29 -0400)
committerAndres Mejia <amejia004@gmail.com>
Fri, 22 Jul 2011 21:29:23 +0000 (17:29 -0400)
SVN-Revision: 3498

libarchive/archive_read_support_format_rar.c

index 0bcffbb558495cfdaacbdf746c114f5d26bb6195..b0356a72888f06a87488f91c453411728ea25548 100644 (file)
@@ -655,6 +655,16 @@ read_header(struct archive_read *a, struct archive_entry *entry,
     rar->unp_size = archive_le32dec(file_header.unp_size);
   }
 
+  /* TODO: Need to use CRC check for these kind of cases.
+   * For now, check if sizes are not < 0.
+   */
+  if (rar->packed_size < 0 || rar->unp_size < 0)
+  {
+    archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+                      "Invalid sizes specified.");
+    return (ARCHIVE_FATAL);
+  }
+
   /* TODO: RARv3 subblocks contain comments. For now the complete block is
    * consumed at the end.
    */