[XZ] Check size of LZMA2 filter properties and throw error if they are wrong

This commit is contained in:
Timofey Solomko
2018-08-15 18:57:21 +03:00
parent 0581c32bd5
commit ea080e13ea
+4 -2
View File
@@ -41,8 +41,10 @@ struct XZBlock {
else { throw XZError.wrongFilterID }
// Only LZMA2 filter is supported.
if filterID == 0x21 {
// First, we need to skip byte with the size of filter's properties
_ = try byteReader.multiByteDecode()
// First, we need to check if size of LZMA2 filter's properties is equal to 1 as expected.
let propertiesSize = try byteReader.multiByteDecode()
guard propertiesSize == 1
else { throw LZMA2Error.wrongDictionarySize }
/// In case of LZMA2 filters property is a dicitonary size.
let filterPropeties = byteReader.byte()
let closure = { (dwp: ByteReader) -> Data in