Repository navigation
squashfs bound decompressed block sizes - #459
Conversation
|
This is nice. I didn't think this could be an issue, but even if not, it is good to have. Why still draft? |
|
need to make some changes to zstd, and also as is now. it could break some usages so I was thinking about introducing the limits with an option. what do you think? Thank you |
OK, sure, can wait. This is OSS, and it is a go library, meaning people always can bind to specific hashes or semvers and not worry about breaking things. So if it is an improvement without breaking something, go for it.
What is the case where it could break something? Either the max size limit is correct, or it is not. If it is not correct, we should not introduce it; if it is correct, then anything that worked before was in error. |
5c74d5e to
c1d290d
Compare
|
ok so in the end I only kept the option to change the default value for zstd, Pr is now ready for review |
c1d290d to
7ff7dd4
Compare
|
add to re-push to address lint errors |
Decompress every block into at most the size its kind allows: a metadata block into 8 KiB, a data or fragment block into the block size of the superblock.
A small, highly compressible block could otherwise expand without bound before any caller saw it.
Decompressors stop as soon as the limit is passed rather than decoding to the end, and fail with the new ErrDecompressedTooLarge.
Added a read option for zstd: WithZstdMaxMemory which sets the decoder history, in bytes, a zstd frame may ask for, by its window or as a single segment. A frame asking for more fails to decompress. The default, 8 MiB, reads the images of mksquashfs and of this package; a larger one reads frames compressed with a larger window, as zstd --long or --ultra may write, at the cost of as much memory per decompression. 0 keeps the default.