tsolomko / SWCompression

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

Crash during GzipArchive.unarchive #57

Open PasiSalenius opened 4 months ago

PasiSalenius commented 4 months ago

I'm seeing crashes for my app that uses SWCompression for Gzip and Deflate decompression. Most probably this is invalid data which isn't actually Gzip compressed, but I'm not exactly sure, as I have never seen this same crash in my own testing of the app.

You can find relevant parts of the stack trace attached below. I'm not too familiar with the code base so did not go ahead with a PR, but maybe there should be a guard check for the last item in the array here, instead of forced unwrap?

Edit: Ah now I notice that the length has 0 items here. Maybe this should be caught earlier before arriving to this method so an error can be thrown for invalid compressed data?

Screenshot 2024-07-15 at 12 58 41 Screenshot 2024-07-15 at 12 58 53