mirror of
https://github.com/tsolomko/SWCompression.git
synced 2026-11-18 21:40:30 +00:00
Fixed padding processing for blocks and index once again.
This commit is contained in:
1 parent
f1f2240867
commit
e8d103776b
1 file changed
+15
-11
+15
-11
@@ -278,11 +278,13 @@ public class XZArchive: Archive {
|
||||
|
||||
let unpaddedSize = pointerData.index - blockHeaderStartIndex
|
||||
|
||||
let paddingSize = unpaddedSize % 4
|
||||
for _ in 0..<paddingSize {
|
||||
let byte = pointerData.alignedByte()
|
||||
guard byte == 0x00
|
||||
else { throw XZError.WrongPadding }
|
||||
if unpaddedSize % 4 != 0 {
|
||||
let paddingSize = 4 - unpaddedSize % 4
|
||||
for _ in 0..<paddingSize {
|
||||
let byte = pointerData.alignedByte()
|
||||
guard byte == 0x00
|
||||
else { throw XZError.WrongPadding }
|
||||
}
|
||||
}
|
||||
|
||||
return (out, unpaddedSize, out.count)
|
||||
@@ -308,12 +310,14 @@ public class XZArchive: Archive {
|
||||
indexBytes.append(contentsOf: uncompSizeTuple.bytesProcessed)
|
||||
}
|
||||
|
||||
let paddingSize = indexBytes.count % 4
|
||||
for _ in 0..<paddingSize {
|
||||
let byte = pointerData.alignedByte()
|
||||
guard byte == 0x00
|
||||
else { throw XZError.WrongPadding }
|
||||
indexBytes.append(byte)
|
||||
if indexBytes.count % 4 != 0 {
|
||||
let paddingSize = 4 - indexBytes.count % 4
|
||||
for _ in 0..<paddingSize {
|
||||
let byte = pointerData.alignedByte()
|
||||
guard byte == 0x00
|
||||
else { throw XZError.WrongPadding }
|
||||
indexBytes.append(byte)
|
||||
}
|
||||
}
|
||||
|
||||
let indexCRC = pointerData.intFromAlignedBytes(count: 4)
|
||||
|
||||
Reference in new issue
Block a user