diff options
| author | Zahir Hussain <zahir.basha@kpit.com> | 2024-01-05 22:02:46 +0530 |
|---|---|---|
| committer | Armin Kuster <akuster808@gmail.com> | 2024-02-07 18:41:40 -0500 |
| commit | 1b1cf2be1e0606024753dd02e0265cbfc37b1a24 (patch) | |
| tree | c644d823103073f8b4e0ef5ab0a3936330d01fd6 /meta-oe/recipes-extended | |
| parent | ce9c0d76171ce9d07e4bcb702b750416b265562a (diff) | |
| download | meta-openembedded-1b1cf2be1e0606024753dd02e0265cbfc37b1a24.tar.gz | |
p7zip: fix CVE-2018-5996 & CVE-2016-9296
References:
https://nvd.nist.gov/vuln/detail/CVE-2018-5996
https://nvd.nist.gov/vuln/detail/CVE-2016-9296
Upstream patches:
https://sources.debian.org/data/non-free/p/p7zip-rar/16.02-3/debian/patches/06-CVE-2018-5996.patch
https://snapshot.debian.org/archive/debian-debug/20180205T215659Z/pool/main/p/p7zip/p7zip_16.02%2Bdfsg-6.debian.tar.xz
Signed-off-by: Zahir Hussain <zahir.basha@kpit.com>
Signed-off-by: aszh07 <mail2szahir@gmail.com>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
Diffstat (limited to 'meta-oe/recipes-extended')
| -rw-r--r-- | meta-oe/recipes-extended/p7zip/files/CVE-2016-9296.patch | 30 | ||||
| -rw-r--r-- | meta-oe/recipes-extended/p7zip/files/CVE-2018-5996.patch | 228 | ||||
| -rw-r--r-- | meta-oe/recipes-extended/p7zip/p7zip_16.02.bb | 2 |
3 files changed, 260 insertions, 0 deletions
diff --git a/meta-oe/recipes-extended/p7zip/files/CVE-2016-9296.patch b/meta-oe/recipes-extended/p7zip/files/CVE-2016-9296.patch new file mode 100644 index 0000000000..42ea716bea --- /dev/null +++ b/meta-oe/recipes-extended/p7zip/files/CVE-2016-9296.patch | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | From: Robert Luberda <robert@debian.org> | ||
| 2 | Date: Sat, 19 Nov 2016 08:48:08 +0100 | ||
| 3 | Subject: Fix nullptr dereference (CVE-2016-9296) | ||
| 4 | |||
| 5 | Patch taken from https://sourceforge.net/p/p7zip/bugs/185/ | ||
| 6 | |||
| 7 | CVE: CVE-2016-9296 | ||
| 8 | |||
| 9 | Upstream-Status: Backport [https://snapshot.debian.org/archive/debian-debug/20180205T215659Z/pool/main/p/p7zip/p7zip_16.02%2Bdfsg-6.debian.tar.xz] | ||
| 10 | |||
| 11 | Signed-off-by: Zahir Hussain <zahir.basha@kpit.com> | ||
| 12 | Signed-off-by: aszh07 <mail2szahir@gmail.com> | ||
| 13 | --- | ||
| 14 | CPP/7zip/Archive/7z/7zIn.cpp | 3 ++- | ||
| 15 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
| 16 | |||
| 17 | diff --git a/CPP/7zip/Archive/7z/7zIn.cpp b/CPP/7zip/Archive/7z/7zIn.cpp | ||
| 18 | index b0c6b98..7c6dde2 100644 | ||
| 19 | --- a/CPP/7zip/Archive/7z/7zIn.cpp | ||
| 20 | +++ b/CPP/7zip/Archive/7z/7zIn.cpp | ||
| 21 | @@ -1097,7 +1097,8 @@ HRESULT CInArchive::ReadAndDecodePackedStreams( | ||
| 22 | if (CrcCalc(data, unpackSize) != folders.FolderCRCs.Vals[i]) | ||
| 23 | ThrowIncorrect(); | ||
| 24 | } | ||
| 25 | - HeadersSize += folders.PackPositions[folders.NumPackStreams]; | ||
| 26 | + if (folders.PackPositions) | ||
| 27 | + HeadersSize += folders.PackPositions[folders.NumPackStreams]; | ||
| 28 | return S_OK; | ||
| 29 | } | ||
| 30 | |||
diff --git a/meta-oe/recipes-extended/p7zip/files/CVE-2018-5996.patch b/meta-oe/recipes-extended/p7zip/files/CVE-2018-5996.patch new file mode 100644 index 0000000000..6b337b8d2d --- /dev/null +++ b/meta-oe/recipes-extended/p7zip/files/CVE-2018-5996.patch | |||
| @@ -0,0 +1,228 @@ | |||
| 1 | From: Robert Luberda <robert@debian.org> | ||
| 2 | Date: Sun, 28 Jan 2018 23:47:40 +0100 | ||
| 3 | Subject: CVE-2018-5996 | ||
| 4 | |||
| 5 | Hopefully fix Memory Corruptions via RAR PPMd (CVE-2018-5996) by | ||
| 6 | applying a few changes from 7Zip 18.00-beta. | ||
| 7 | |||
| 8 | Bug-Debian: https://bugs.debian.org/#888314 | ||
| 9 | |||
| 10 | CVE: CVE-2018-5996 | ||
| 11 | |||
| 12 | Upstream-Status: Backport [https://sources.debian.org/data/non-free/p/p7zip-rar/16.02-3/debian/patches/06-CVE-2018-5996.patch] | ||
| 13 | |||
| 14 | Signed-off-by: Zahir Hussain <zahir.basha@kpit.com> | ||
| 15 | Signed-off-by: aszh07 <mail2szahir@gmail.com> | ||
| 16 | --- | ||
| 17 | CPP/7zip/Compress/Rar1Decoder.cpp | 13 +++++++++---- | ||
| 18 | CPP/7zip/Compress/Rar1Decoder.h | 1 + | ||
| 19 | CPP/7zip/Compress/Rar2Decoder.cpp | 10 +++++++++- | ||
| 20 | CPP/7zip/Compress/Rar2Decoder.h | 1 + | ||
| 21 | CPP/7zip/Compress/Rar3Decoder.cpp | 23 ++++++++++++++++++++--- | ||
| 22 | CPP/7zip/Compress/Rar3Decoder.h | 2 ++ | ||
| 23 | 6 files changed, 42 insertions(+), 8 deletions(-) | ||
| 24 | |||
| 25 | diff --git a/CPP/7zip/Compress/Rar1Decoder.cpp b/CPP/7zip/Compress/Rar1Decoder.cpp | ||
| 26 | index 1aaedcc..68030c7 100644 | ||
| 27 | --- a/CPP/7zip/Compress/Rar1Decoder.cpp | ||
| 28 | +++ b/CPP/7zip/Compress/Rar1Decoder.cpp | ||
| 29 | @@ -29,7 +29,7 @@ public: | ||
| 30 | }; | ||
| 31 | */ | ||
| 32 | |||
| 33 | -CDecoder::CDecoder(): m_IsSolid(false) { } | ||
| 34 | +CDecoder::CDecoder(): m_IsSolid(false), _errorMode(false) { } | ||
| 35 | |||
| 36 | void CDecoder::InitStructures() | ||
| 37 | { | ||
| 38 | @@ -406,9 +406,14 @@ HRESULT CDecoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream * | ||
| 39 | InitData(); | ||
| 40 | if (!m_IsSolid) | ||
| 41 | { | ||
| 42 | + _errorMode = false; | ||
| 43 | InitStructures(); | ||
| 44 | InitHuff(); | ||
| 45 | } | ||
| 46 | + | ||
| 47 | + if (_errorMode) | ||
| 48 | + return S_FALSE; | ||
| 49 | + | ||
| 50 | if (m_UnpackSize > 0) | ||
| 51 | { | ||
| 52 | GetFlagsBuf(); | ||
| 53 | @@ -477,9 +482,9 @@ STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream | ||
| 54 | const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress) | ||
| 55 | { | ||
| 56 | try { return CodeReal(inStream, outStream, inSize, outSize, progress); } | ||
| 57 | - catch(const CInBufferException &e) { return e.ErrorCode; } | ||
| 58 | - catch(const CLzOutWindowException &e) { return e.ErrorCode; } | ||
| 59 | - catch(...) { return S_FALSE; } | ||
| 60 | + catch(const CInBufferException &e) { _errorMode = true; return e.ErrorCode; } | ||
| 61 | + catch(const CLzOutWindowException &e) { _errorMode = true; return e.ErrorCode; } | ||
| 62 | + catch(...) { _errorMode = true; return S_FALSE; } | ||
| 63 | } | ||
| 64 | |||
| 65 | STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *data, UInt32 size) | ||
| 66 | diff --git a/CPP/7zip/Compress/Rar1Decoder.h b/CPP/7zip/Compress/Rar1Decoder.h | ||
| 67 | index 630f089..01b606b 100644 | ||
| 68 | --- a/CPP/7zip/Compress/Rar1Decoder.h | ||
| 69 | +++ b/CPP/7zip/Compress/Rar1Decoder.h | ||
| 70 | @@ -39,6 +39,7 @@ public: | ||
| 71 | |||
| 72 | Int64 m_UnpackSize; | ||
| 73 | bool m_IsSolid; | ||
| 74 | + bool _errorMode; | ||
| 75 | |||
| 76 | UInt32 ReadBits(int numBits); | ||
| 77 | HRESULT CopyBlock(UInt32 distance, UInt32 len); | ||
| 78 | diff --git a/CPP/7zip/Compress/Rar2Decoder.cpp b/CPP/7zip/Compress/Rar2Decoder.cpp | ||
| 79 | index b3f2b4b..0580c8d 100644 | ||
| 80 | --- a/CPP/7zip/Compress/Rar2Decoder.cpp | ||
| 81 | +++ b/CPP/7zip/Compress/Rar2Decoder.cpp | ||
| 82 | @@ -80,7 +80,8 @@ static const UInt32 kHistorySize = 1 << 20; | ||
| 83 | static const UInt32 kWindowReservSize = (1 << 22) + 256; | ||
| 84 | |||
| 85 | CDecoder::CDecoder(): | ||
| 86 | - m_IsSolid(false) | ||
| 87 | + m_IsSolid(false), | ||
| 88 | + m_TablesOK(false) | ||
| 89 | { | ||
| 90 | } | ||
| 91 | |||
| 92 | @@ -100,6 +101,8 @@ UInt32 CDecoder::ReadBits(unsigned numBits) { return m_InBitStream.ReadBits(numB | ||
| 93 | |||
| 94 | bool CDecoder::ReadTables(void) | ||
| 95 | { | ||
| 96 | + m_TablesOK = false; | ||
| 97 | + | ||
| 98 | Byte levelLevels[kLevelTableSize]; | ||
| 99 | Byte newLevels[kMaxTableSize]; | ||
| 100 | m_AudioMode = (ReadBits(1) == 1); | ||
| 101 | @@ -170,6 +173,8 @@ bool CDecoder::ReadTables(void) | ||
| 102 | } | ||
| 103 | |||
| 104 | memcpy(m_LastLevels, newLevels, kMaxTableSize); | ||
| 105 | + m_TablesOK = true; | ||
| 106 | + | ||
| 107 | return true; | ||
| 108 | } | ||
| 109 | |||
| 110 | @@ -344,6 +349,9 @@ HRESULT CDecoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream * | ||
| 111 | return S_FALSE; | ||
| 112 | } | ||
| 113 | |||
| 114 | + if (!m_TablesOK) | ||
| 115 | + return S_FALSE; | ||
| 116 | + | ||
| 117 | UInt64 startPos = m_OutWindowStream.GetProcessedSize(); | ||
| 118 | while (pos < unPackSize) | ||
| 119 | { | ||
| 120 | diff --git a/CPP/7zip/Compress/Rar2Decoder.h b/CPP/7zip/Compress/Rar2Decoder.h | ||
| 121 | index 3a0535c..0e9005f 100644 | ||
| 122 | --- a/CPP/7zip/Compress/Rar2Decoder.h | ||
| 123 | +++ b/CPP/7zip/Compress/Rar2Decoder.h | ||
| 124 | @@ -139,6 +139,7 @@ class CDecoder : | ||
| 125 | |||
| 126 | UInt64 m_PackSize; | ||
| 127 | bool m_IsSolid; | ||
| 128 | + bool m_TablesOK; | ||
| 129 | |||
| 130 | void InitStructures(); | ||
| 131 | UInt32 ReadBits(unsigned numBits); | ||
| 132 | diff --git a/CPP/7zip/Compress/Rar3Decoder.cpp b/CPP/7zip/Compress/Rar3Decoder.cpp | ||
| 133 | index 3bf2513..6cb8a6a 100644 | ||
| 134 | --- a/CPP/7zip/Compress/Rar3Decoder.cpp | ||
| 135 | +++ b/CPP/7zip/Compress/Rar3Decoder.cpp | ||
| 136 | @@ -92,7 +92,8 @@ CDecoder::CDecoder(): | ||
| 137 | _writtenFileSize(0), | ||
| 138 | _vmData(0), | ||
| 139 | _vmCode(0), | ||
| 140 | - m_IsSolid(false) | ||
| 141 | + m_IsSolid(false), | ||
| 142 | + _errorMode(false) | ||
| 143 | { | ||
| 144 | Ppmd7_Construct(&_ppmd); | ||
| 145 | } | ||
| 146 | @@ -545,6 +546,9 @@ HRESULT CDecoder::ReadTables(bool &keepDecompressing) | ||
| 147 | return InitPPM(); | ||
| 148 | } | ||
| 149 | |||
| 150 | + TablesRead = false; | ||
| 151 | + TablesOK = false; | ||
| 152 | + | ||
| 153 | _lzMode = true; | ||
| 154 | PrevAlignBits = 0; | ||
| 155 | PrevAlignCount = 0; | ||
| 156 | @@ -606,6 +610,9 @@ HRESULT CDecoder::ReadTables(bool &keepDecompressing) | ||
| 157 | } | ||
| 158 | } | ||
| 159 | } | ||
| 160 | + if (InputEofError()) | ||
| 161 | + return S_FALSE; | ||
| 162 | + | ||
| 163 | TablesRead = true; | ||
| 164 | |||
| 165 | // original code has check here: | ||
| 166 | @@ -623,6 +630,9 @@ HRESULT CDecoder::ReadTables(bool &keepDecompressing) | ||
| 167 | RIF(m_LenDecoder.Build(&newLevels[kMainTableSize + kDistTableSize + kAlignTableSize])); | ||
| 168 | |||
| 169 | memcpy(m_LastLevels, newLevels, kTablesSizesSum); | ||
| 170 | + | ||
| 171 | + TablesOK = true; | ||
| 172 | + | ||
| 173 | return S_OK; | ||
| 174 | } | ||
| 175 | |||
| 176 | @@ -824,7 +834,12 @@ HRESULT CDecoder::CodeReal(ICompressProgressInfo *progress) | ||
| 177 | PpmEscChar = 2; | ||
| 178 | PpmError = true; | ||
| 179 | InitFilters(); | ||
| 180 | + _errorMode = false; | ||
| 181 | } | ||
| 182 | + | ||
| 183 | + if (_errorMode) | ||
| 184 | + return S_FALSE; | ||
| 185 | + | ||
| 186 | if (!m_IsSolid || !TablesRead) | ||
| 187 | { | ||
| 188 | bool keepDecompressing; | ||
| 189 | @@ -838,6 +853,8 @@ HRESULT CDecoder::CodeReal(ICompressProgressInfo *progress) | ||
| 190 | bool keepDecompressing; | ||
| 191 | if (_lzMode) | ||
| 192 | { | ||
| 193 | + if (!TablesOK) | ||
| 194 | + return S_FALSE; | ||
| 195 | RINOK(DecodeLZ(keepDecompressing)) | ||
| 196 | } | ||
| 197 | else | ||
| 198 | @@ -901,8 +918,8 @@ STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream | ||
| 199 | _unpackSize = outSize ? *outSize : (UInt64)(Int64)-1; | ||
| 200 | return CodeReal(progress); | ||
| 201 | } | ||
| 202 | - catch(const CInBufferException &e) { return e.ErrorCode; } | ||
| 203 | - catch(...) { return S_FALSE; } | ||
| 204 | + catch(const CInBufferException &e) { _errorMode = true; return e.ErrorCode; } | ||
| 205 | + catch(...) { _errorMode = true; return S_FALSE; } | ||
| 206 | // CNewException is possible here. But probably CNewException is caused | ||
| 207 | // by error in data stream. | ||
| 208 | } | ||
| 209 | diff --git a/CPP/7zip/Compress/Rar3Decoder.h b/CPP/7zip/Compress/Rar3Decoder.h | ||
| 210 | index c130cec..2f72d7d 100644 | ||
| 211 | --- a/CPP/7zip/Compress/Rar3Decoder.h | ||
| 212 | +++ b/CPP/7zip/Compress/Rar3Decoder.h | ||
| 213 | @@ -192,6 +192,7 @@ class CDecoder: | ||
| 214 | UInt32 _lastFilter; | ||
| 215 | |||
| 216 | bool m_IsSolid; | ||
| 217 | + bool _errorMode; | ||
| 218 | |||
| 219 | bool _lzMode; | ||
| 220 | bool _unsupportedFilter; | ||
| 221 | @@ -200,6 +201,7 @@ class CDecoder: | ||
| 222 | UInt32 PrevAlignCount; | ||
| 223 | |||
| 224 | bool TablesRead; | ||
| 225 | + bool TablesOK; | ||
| 226 | |||
| 227 | CPpmd7 _ppmd; | ||
| 228 | int PpmEscChar; | ||
diff --git a/meta-oe/recipes-extended/p7zip/p7zip_16.02.bb b/meta-oe/recipes-extended/p7zip/p7zip_16.02.bb index 04923116cf..e795482eb6 100644 --- a/meta-oe/recipes-extended/p7zip/p7zip_16.02.bb +++ b/meta-oe/recipes-extended/p7zip/p7zip_16.02.bb | |||
| @@ -10,6 +10,8 @@ SRC_URI = "http://downloads.sourceforge.net/p7zip/p7zip/${PV}/p7zip_${PV}_src_al | |||
| 10 | file://CVE-2017-17969.patch \ | 10 | file://CVE-2017-17969.patch \ |
| 11 | file://0001-Fix-narrowing-errors-Wc-11-narrowing.patch \ | 11 | file://0001-Fix-narrowing-errors-Wc-11-narrowing.patch \ |
| 12 | file://change_numMethods_from_bool_to_unsigned.patch \ | 12 | file://change_numMethods_from_bool_to_unsigned.patch \ |
| 13 | file://CVE-2018-5996.patch \ | ||
| 14 | file://CVE-2016-9296.patch \ | ||
| 13 | " | 15 | " |
| 14 | 16 | ||
| 15 | SRC_URI[md5sum] = "a0128d661cfe7cc8c121e73519c54fbf" | 17 | SRC_URI[md5sum] = "a0128d661cfe7cc8c121e73519c54fbf" |
