2015.06.12 08:08 "Re: [Tiff] Long standing bug in LibTIFF LZW compression", by Andy Cave
Hi Lee,
Your change is correct in both cases (I looked at the diff you posted), in terms of what I mailed.
I checked the latest source, which differs slightly from my older source, but the change is still valid (and correct).
The only thing is that in the latest source there is a (new from my code) test shortly after the change you made, on "if (code >= CODE_CLEAR) {", which I would suggest should be after your/my change just ">" (as the test on ">=" is now clearly redundant in the "==" case).
Thanks for doing that.
Regards,
Andy.
Attached is the untested patch. (I'm merely following Andy's instructions in creating a patch for him.)
On 05/08/2015 10:51 AM, Andy Cave wrote:
Dear All,
There is a longstanding bug in the LZW decompressor in LibTIFF. It
> fails to decode files that contain two consecutive CODE_CLEAR codes.
> These are allowed by the LZW spec and the same data sequence is > correctly decoded by Acrobat if you wrap the data in a PDF file.
The fix is simple:
- Add "do {" after the line "if (code == CODE_CLEAR) {" in both
- LZWDecode and LZWDecodeCompat.
- Add "} while (code == CODE_CLEAR);" before the line " if (code == CODE_EOI)" (half a dozen lines or so down from the first change) in
- both LZWDecode and LZWDecodeCompat.
- I have no idea how to submit a diff of the fix or fix the public
- domain source, so if someone could help who knows how to, it should do
> no harm to fix the bug.