-
Notifications
You must be signed in to change notification settings - Fork 5
Description
This is to discuss if there is something to be done by fdeflate or not. Also, compare handling in weezl.
In png the InsufficientInput error can occur when flushing data from the sequence of zlib-copmressed IDAT chunks. When that happens, decoding will return an error. However, this error depends on the number of bytes the Read feeds to the decoder at once. We only flush (by setting end_of_input) when we have completely read the last IDAT chunk. Having smaller amounts of data at once will therefore read more often with a read call set end_of_input false.
A problem now occurs if the zlib stream is 'corrupt', i.e. missing a proper end. It can still contain sufficient amounts of data for pixel decoding to work, partially or fully. Given the above usage, the last fdeflate read call will definitely return an error. That is fine by itself, the mitigation strategy is on png. However, the amount of bytes ever indicated by output_consumed depends on input data chunks, and the respecitvely available output chunks! Tather tragically, if we feed data in smaller chunks (we setup the output chunk to a fixed additional length) the decoder has more opportunities to write output data we actually receive. In large-chunk calls however more of the data is suppressed with the final read that errors, so bigger portions of the data stream are also lost.
Compare to weezl:
- an error return in
fdeflatedoes not carry any of the input / output consumption information, inweezlthe offsets are always available. weezlsuppressesInsufficientInput(which is a non-errorLzwStatus::NoProgress) if any progress was made in the read.