1 Patch based on analysis of the fix in upstream 7-zip at
3 https://landave.io/files/patch_7zip_CVE-2018-10115.txt
5 diff -pruN '--exclude=*.orig' p7zip_16.02~/CPP/7zip/Compress/Rar1Decoder.cpp p7zip_16.02/CPP/7zip/Compress/Rar1Decoder.cpp
6 --- p7zip_16.02~/CPP/7zip/Compress/Rar1Decoder.cpp 2018-05-02 15:06:58.034027678 +0000
7 +++ p7zip_16.02/CPP/7zip/Compress/Rar1Decoder.cpp 2018-05-02 15:06:58.162661972 +0000
8 @@ -29,7 +29,12 @@ public:
12 -CDecoder::CDecoder(): m_IsSolid(false), _errorMode(false) { }
13 +CDecoder::CDecoder():
15 + m_solidAllowed(false),
20 void CDecoder::InitStructures()
22 @@ -391,6 +396,11 @@ HRESULT CDecoder::CodeReal(ISequentialIn
23 if (inSize == NULL || outSize == NULL)
26 + if (m_IsSolid && !m_solidAllowed)
29 + m_solidAllowed = false;
31 if (!m_OutWindowStream.Create(kHistorySize))
33 if (!m_InBitStream.Create(1 << 20))
34 @@ -473,6 +483,7 @@ HRESULT CDecoder::CodeReal(ISequentialIn
38 + m_solidAllowed = true;
41 return m_OutWindowStream.Flush();
42 diff -pruN '--exclude=*.orig' p7zip_16.02~/CPP/7zip/Compress/Rar1Decoder.h p7zip_16.02/CPP/7zip/Compress/Rar1Decoder.h
43 --- p7zip_16.02~/CPP/7zip/Compress/Rar1Decoder.h 2018-05-02 15:06:58.034273736 +0000
44 +++ p7zip_16.02/CPP/7zip/Compress/Rar1Decoder.h 2018-05-02 15:06:58.162871572 +0000
45 @@ -39,6 +39,7 @@ public:
49 + bool m_solidAllowed;
52 UInt32 ReadBits(int numBits);
53 diff -pruN '--exclude=*.orig' p7zip_16.02~/CPP/7zip/Compress/Rar2Decoder.cpp p7zip_16.02/CPP/7zip/Compress/Rar2Decoder.cpp
54 --- p7zip_16.02~/CPP/7zip/Compress/Rar2Decoder.cpp 2018-05-02 15:06:58.034541629 +0000
55 +++ p7zip_16.02/CPP/7zip/Compress/Rar2Decoder.cpp 2018-05-02 15:06:58.163128844 +0000
56 @@ -81,6 +81,7 @@ static const UInt32 kWindowReservSize =
60 + m_solidAllowed(false),
64 @@ -320,6 +321,10 @@ HRESULT CDecoder::CodeReal(ISequentialIn
65 if (inSize == NULL || outSize == NULL)
68 + if (m_IsSolid && !m_solidAllowed)
70 + m_solidAllowed = false;
72 if (!m_OutWindowStream.Create(kHistorySize))
74 if (!m_InBitStream.Create(1 << 20))
75 @@ -343,6 +348,7 @@ HRESULT CDecoder::CodeReal(ISequentialIn
76 if (m_InBitStream.GetProcessedSize() + 2 <= m_PackSize) // test it: probably incorrect;
79 + m_solidAllowed = true;
83 @@ -386,6 +392,7 @@ HRESULT CDecoder::CodeReal(ISequentialIn
85 if (!ReadLastTables())
87 + m_solidAllowed = true;
88 return m_OutWindowStream.Flush();
91 diff -pruN '--exclude=*.orig' p7zip_16.02~/CPP/7zip/Compress/Rar2Decoder.h p7zip_16.02/CPP/7zip/Compress/Rar2Decoder.h
92 --- p7zip_16.02~/CPP/7zip/Compress/Rar2Decoder.h 2018-05-02 15:06:58.034736908 +0000
93 +++ p7zip_16.02/CPP/7zip/Compress/Rar2Decoder.h 2018-05-02 15:06:58.163323313 +0000
94 @@ -139,6 +139,7 @@ class CDecoder :
98 + bool m_solidAllowed;
101 void InitStructures();
102 diff -pruN '--exclude=*.orig' p7zip_16.02~/CPP/7zip/Compress/Rar3Decoder.cpp p7zip_16.02/CPP/7zip/Compress/Rar3Decoder.cpp
103 --- p7zip_16.02~/CPP/7zip/Compress/Rar3Decoder.cpp 2018-05-02 15:06:58.035151069 +0000
104 +++ p7zip_16.02/CPP/7zip/Compress/Rar3Decoder.cpp 2018-05-02 15:06:58.163692811 +0000
105 @@ -93,6 +93,7 @@ CDecoder::CDecoder():
109 + m_solidAllowed(false),
112 Ppmd7_Construct(&_ppmd);
113 @@ -845,7 +846,10 @@ HRESULT CDecoder::CodeReal(ICompressProg
114 bool keepDecompressing;
115 RINOK(ReadTables(keepDecompressing));
116 if (!keepDecompressing)
118 + m_solidAllowed = true;
124 @@ -870,6 +874,7 @@ HRESULT CDecoder::CodeReal(ICompressProg
125 if (!keepDecompressing)
128 + m_solidAllowed = true;
130 UInt64 packSize = m_InBitStream.BitDecoder.GetProcessedSize();
131 RINOK(progress->SetRatioInfo(&packSize, &_writtenFileSize));
132 @@ -890,6 +895,10 @@ STDMETHODIMP CDecoder::Code(ISequentialI
136 + if (m_IsSolid && !m_solidAllowed)
138 + m_solidAllowed = false;
142 _vmData = (Byte *)::MidAlloc(kVmDataSizeMax + kVmCodeSizeMax);
143 diff -pruN '--exclude=*.orig' p7zip_16.02~/CPP/7zip/Compress/Rar3Decoder.h p7zip_16.02/CPP/7zip/Compress/Rar3Decoder.h
144 --- p7zip_16.02~/CPP/7zip/Compress/Rar3Decoder.h 2018-05-02 15:06:58.035371032 +0000
145 +++ p7zip_16.02/CPP/7zip/Compress/Rar3Decoder.h 2018-05-02 15:06:58.163919947 +0000
146 @@ -192,6 +192,7 @@ class CDecoder:
150 + bool m_solidAllowed;
154 diff -pruN '--exclude=*.orig' p7zip_16.02~/CPP/7zip/Compress/Rar5Decoder.cpp p7zip_16.02/CPP/7zip/Compress/Rar5Decoder.cpp
155 --- p7zip_16.02~/CPP/7zip/Compress/Rar5Decoder.cpp 2016-05-20 08:20:04.000000000 +0000
156 +++ p7zip_16.02/CPP/7zip/Compress/Rar5Decoder.cpp 2018-05-02 15:06:58.164239702 +0000
157 @@ -72,6 +72,7 @@ CDecoder::CDecoder():
161 + _solidAllowed(false),
165 @@ -801,7 +802,10 @@ HRESULT CDecoder::CodeReal()
170 + _solidAllowed = true;
174 if (res == S_OK && _unpackSize_Defined && _writtenFileSize != _unpackSize)
176 @@ -821,6 +825,9 @@ STDMETHODIMP CDecoder::Code(ISequentialI
180 + if (_isSolid && !_solidAllowed)
182 + _solidAllowed = false;
183 if (_dictSizeLog >= sizeof(size_t) * 8)
186 diff -pruN '--exclude=*.orig' p7zip_16.02~/CPP/7zip/Compress/Rar5Decoder.h p7zip_16.02/CPP/7zip/Compress/Rar5Decoder.h
187 --- p7zip_16.02~/CPP/7zip/Compress/Rar5Decoder.h 2015-09-01 18:04:50.000000000 +0000
188 +++ p7zip_16.02/CPP/7zip/Compress/Rar5Decoder.h 2018-05-02 15:06:58.164455518 +0000
189 @@ -271,6 +271,7 @@ class CDecoder:
191 bool _tableWasFilled;
193 + bool _solidAllowed;
196 UInt32 _reps[kNumReps];