[BZ#2073] TIFFWriteScanline corrupts buffer when compression with predication is enabled
Submitted by William B Thompson (thompson at cs dot utah dot edu) on 2009-06-30 18:14
Description
Created an attachment (id=319)
test progam
TIFFWriteScanline corrupts the input buffer in the calling program with LZW and deflate (zip) compression when horizontal prediction is enabled for integer values or floating point prediction is enable for floating point values. This occurs with both libtiff 3.8.2 and 4.0.0beta3 (CVS).
A test program for the integer case is attached. It should be run with and without the "-p" flag.
The declaration of TIFFWriteScanline does not include the "const" qualifier for the buffer argument, so modifying values in the buffer is not, strictly speaking, in violation of the specification. It seems to me, however, that it is bad practice. It is certainly bad practice when not described in the man page for TIFFWriteScanline.
One might argue that it is rare to rewrite or otherwise reuse an output buffer that has just been written to a file. I can testify from personal experience that it might be rare, but it does occur (and is a pain to track down when it happens).
Attachment 319, "test progam":
compression_with_prediction.c