tayloraswift / swift-png

decode, inspect, edit, and encode png images in pure swift

Home Page:https://swiftinit.org/docs/swift-png

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Gzip compression API should be failable, and return nil for very short inputs

tayloraswift opened this issue · comments

calling the compression API with data shorter than 2 bytes is violating many preconditions, leading to runtime crashes!

it would never make sense to run a compression algorithm on data that small. the compressed file would be dozens of times larger than the original input. we should impose a minimum data length of at least 8 bytes, or implement a separate path using https://commandlinefanatic.com/cgi-bin/showarticle.cgi?article=art053 as inspiration

okay, it looks like i just made things worse.

this should be finally fixed. lesson learned: using gzip to decode PNG is not as comprehensive a test for gzip as we thought