From: Andres Mejia Date: Fri, 22 Jul 2011 21:29:23 +0000 (-0400) Subject: Make sure sizes for RAR files are valid. X-Git-Tag: v3.0.0a~230 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aec2fa1feae445cb0539374aade24c16826e4c9f;p=thirdparty%2Flibarchive.git Make sure sizes for RAR files are valid. SVN-Revision: 3498 --- diff --git a/libarchive/archive_read_support_format_rar.c b/libarchive/archive_read_support_format_rar.c index 0bcffbb55..b0356a728 100644 --- a/libarchive/archive_read_support_format_rar.c +++ b/libarchive/archive_read_support_format_rar.c @@ -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. */