Fail with negative lha->compsize in lha_read_file_header_1() Fixes a heap buffer... 83/134783/1 submit/tizen_base/20170620.051947
authorMartin Matuska <martin@matuska.org>
Thu, 19 Jan 2017 21:00:18 +0000 (22:00 +0100)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Tue, 20 Jun 2017 04:24:01 +0000 (13:24 +0900)
Change-Id: Ifd42aa5e066d5ac401c934406552ae0fa311730e
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
libarchive/archive_read_support_format_lha.c

index c359d83..1a5617f 100644 (file)
@@ -924,6 +924,9 @@ lha_read_file_header_1(struct archive_read *a, struct lha *lha)
        /* Get a real compressed file size. */
        lha->compsize -= extdsize - 2;
 
+       if (lha->compsize < 0)
+               goto invalid;   /* Invalid compressed file size */
+
        if (sum_calculated != headersum) {
                archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
                    "LHa header sum error");