diff --git a/CHANGELOG.md b/CHANGELOG.md index d621c8e9..60c8c480 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,10 @@ v3.0.0 - In CocoaPods configurations availability of such support depends on the presence of corresponding podspecs. +v2.4.3 +---------------- +- Fixed incorrect calculation of header's checksum for GZip archives. + v2.4.2 ---------------- - Fixed a problem, where ZipEntry.fileName was returning fileComment instead. diff --git a/Sources/GzipArchive.swift b/Sources/GzipArchive.swift index 8ba6c6bc..007a4d8f 100644 --- a/Sources/GzipArchive.swift +++ b/Sources/GzipArchive.swift @@ -95,7 +95,6 @@ public struct GzipHeader { - Throws: `GzipError`. It may indicate that either the data is damaged or it might not be compressed with gzip at all. */ - public init(archiveData: Data) throws { let pointerData = DataWithPointer(data: archiveData, bitOrder: .reversed) try self.init(pointerData) @@ -148,9 +147,9 @@ public struct GzipHeader { var fnameBytes: [UInt8] = [] while true { let byte = pointerData.alignedByte() + headerBytes.append(byte) guard byte != 0 else { break } fnameBytes.append(byte) - headerBytes.append(byte) } self.originalFileName = String(data: Data(fnameBytes), encoding: .utf8) } else { @@ -162,9 +161,9 @@ public struct GzipHeader { var fcommentBytes: [UInt8] = [] while true { let byte = pointerData.alignedByte() + headerBytes.append(byte) guard byte != 0 else { break } fcommentBytes.append(byte) - headerBytes.append(byte) } self.comment = String(data: Data(fcommentBytes), encoding: .utf8) } else {