tsolomko / SWCompression

A Swift framework for working with compression, archives and containers.
MIT License
238 stars 41 forks source link

BZip2Error.wrongCRC when decompressing #38

Closed MBLRN closed 1 year ago

MBLRN commented 1 year ago

Hello I’m getting a BZip2Error.wrongCRC error using BZip2 with the following file: problem.dat.zip The file needs decompressing first before using:

let uncompressed = try Data(contentsOf: "problem.dat")
let compressed = BZip2.compress(data: uncompressed)
let backAgain = try BZip2.decompress(data: compressed)

Cheers.

tsolomko commented 1 year ago

Thank you for reporting this issue! It is very peculiar and in fact quite serious.

As it turns out it is not related to CRC computation. Instead, the so called "pointer" was set incorrectly in Burrows-Wheeler transform during BZip2 compression. I am very surprised that no one has encountered this problem until now.

This issue was fixed in b1fe47fdbb39afa08715940e7d738fff362034b7.

tsolomko commented 1 year ago

The fix was released as part of the 4.8.4 update.