summaryrefslogtreecommitdiffstats
path: root/recipes-extended/libarchive/libarchive/CVE-2017-5601.patch
blob: a5298f57992c3b42e78065751de79ba7e314d6bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
From 98dcbbf0bf4854bf987557e55e55fff7abbf3ea9 Mon Sep 17 00:00:00 2001
From: Martin Matuska <martin@matuska.org>
Date: Thu, 19 Jan 2017 22:00:18 +0100
Subject: [PATCH] Fail with negative lha->compsize in lha_read_file_header_1()
 Fixes a heap buffer overflow reported in Secunia SA74169

CVE: CVE-2017-5601
Upstream-Status: Backport [https://github.com/libarchive/libarchive/commit/98dcbbf0bf4854bf987557e55e55fff7abbf3ea9.patch]

Signed-off-by: Sona Sarmadi <sona.sarmadi@enea.com>
---
 libarchive/archive_read_support_format_lha.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libarchive/archive_read_support_format_lha.c b/libarchive/archive_read_support_format_lha.c
index 52a5531b0..d77a7c2e4 100644
--- a/libarchive/archive_read_support_format_lha.c
+++ b/libarchive/archive_read_support_format_lha.c
@@ -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");