1*eb8dc403SDave Cobbleyp7zip: Fix CVE-2017-17969
2*eb8dc403SDave Cobbley
3*eb8dc403SDave Cobbley[No upstream tracking] -- https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=888297
4*eb8dc403SDave Cobbley
5*eb8dc403SDave CobbleyHeap-based buffer overflow in 7zip
6*eb8dc403SDave Cobbley
7*eb8dc403SDave CobbleyCompress/ShrinkDecoder.cpp: Heap-based buffer overflow
8*eb8dc403SDave Cobbleyin the NCompress::NShrink::CDecoder::CodeReal method
9*eb8dc403SDave Cobbleyin 7-Zip before 18.00 and p7zip allows remote attackers
10*eb8dc403SDave Cobbleyto cause a denial of service (out-of-bounds write)
11*eb8dc403SDave Cobbleyor potentially execute arbitrary code via a crafted ZIP archive.
12*eb8dc403SDave Cobbley
13*eb8dc403SDave CobbleyUpstream-Status: Backport [https://sourceforge.net/p/p7zip/bugs/_discuss/thread/0920f369/8316/attachment/CVE-2017-17969.patch]
14*eb8dc403SDave CobbleyCVE: CVE-2017-17969
15*eb8dc403SDave CobbleySigned-off-by: Radovan Scasny <radovan.scasny@siemens.com>
16*eb8dc403SDave Cobbley
17*eb8dc403SDave Cobbley--- a/CPP/7zip/Compress/ShrinkDecoder.cpp
18*eb8dc403SDave Cobbley+++ b/CPP/7zip/Compress/ShrinkDecoder.cpp
19*eb8dc403SDave Cobbley@@ -121,7 +121,12 @@ HRESULT CDecoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *
20*eb8dc403SDave Cobbley     {
21*eb8dc403SDave Cobbley       _stack[i++] = _suffixes[cur];
22*eb8dc403SDave Cobbley       cur = _parents[cur];
23*eb8dc403SDave Cobbley+	  if (cur >= kNumItems || i >= kNumItems)
24*eb8dc403SDave Cobbley+	  	break;
25*eb8dc403SDave Cobbley     }
26*eb8dc403SDave Cobbley+
27*eb8dc403SDave Cobbley+	if (cur >= kNumItems || i >= kNumItems)
28*eb8dc403SDave Cobbley+		break;
29*eb8dc403SDave Cobbley
30*eb8dc403SDave Cobbley     _stack[i++] = (Byte)cur;
31*eb8dc403SDave Cobbley     lastChar2 = (Byte)cur;
32