William A. Kennington III | b95905d | 2021-06-02 12:40:56 -0700 | [diff] [blame] | 1 | From 7f2da4f810b429ddb7afa0e252e3d02ced0eba87 Mon Sep 17 00:00:00 2001 |
| 2 | From: Radovan Scasny <radovan.scasny@siemens.com> |
| 3 | Date: Tue, 20 Feb 2018 12:08:13 +0100 |
| 4 | Subject: [PATCH] p7zip: Fix CVE-2017-17969 |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 5 | |
| 6 | [No upstream tracking] -- https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=888297 |
| 7 | |
| 8 | Heap-based buffer overflow in 7zip |
| 9 | |
| 10 | Compress/ShrinkDecoder.cpp: Heap-based buffer overflow |
| 11 | in the NCompress::NShrink::CDecoder::CodeReal method |
| 12 | in 7-Zip before 18.00 and p7zip allows remote attackers |
| 13 | to cause a denial of service (out-of-bounds write) |
William A. Kennington III | b95905d | 2021-06-02 12:40:56 -0700 | [diff] [blame] | 14 | or potentially execute arbitrary code via a crafted ZIP archive. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 15 | |
| 16 | Upstream-Status: Backport [https://sourceforge.net/p/p7zip/bugs/_discuss/thread/0920f369/8316/attachment/CVE-2017-17969.patch] |
| 17 | CVE: CVE-2017-17969 |
| 18 | Signed-off-by: Radovan Scasny <radovan.scasny@siemens.com> |
| 19 | |
William A. Kennington III | b95905d | 2021-06-02 12:40:56 -0700 | [diff] [blame] | 20 | --- |
| 21 | CPP/7zip/Compress/ShrinkDecoder.cpp | 5 +++++ |
| 22 | 1 file changed, 5 insertions(+) |
| 23 | |
| 24 | diff --git a/CPP/7zip/Compress/ShrinkDecoder.cpp b/CPP/7zip/Compress/ShrinkDecoder.cpp |
| 25 | index 80b7e67..5bb0559 100644 |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 26 | --- a/CPP/7zip/Compress/ShrinkDecoder.cpp |
| 27 | +++ b/CPP/7zip/Compress/ShrinkDecoder.cpp |
| 28 | @@ -121,7 +121,12 @@ HRESULT CDecoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream * |
| 29 | { |
| 30 | _stack[i++] = _suffixes[cur]; |
| 31 | cur = _parents[cur]; |
| 32 | + if (cur >= kNumItems || i >= kNumItems) |
| 33 | + break; |
| 34 | } |
| 35 | + |
| 36 | + if (cur >= kNumItems || i >= kNumItems) |
| 37 | + break; |
| 38 | |
| 39 | _stack[i++] = (Byte)cur; |
| 40 | lastChar2 = (Byte)cur; |