2016.08.07 03:52 "[Tiff] fax2tiff in libtiff 4.0.5 and 4.0.6", by Steve Underwood

2016.08.07 03:52 "[Tiff] fax2tiff in libtiff 4.0.5 and 4.0.6", by Steve Underwood

Hi all,

Up to libtiff 4.0.4 the fax2tiff utility worked OK. In libtiff 4.0.5 and 4.0.6 it is broken. On Linux machines it says "Not enough memory" for any G3 fax file you pass to it. I have not tested with OS/X or Windows.

if I use the fax2tiff.c file from libtiff 4.0.4 with libtiff 4.0.6 everything works OK. Someone changed the way client data is handled in fax2tiff.c, and I don't understand what they were trying to achieve. This means I am not certain that going back to the version from 4.0.4 is really the right thing to do. Below is a diff between the 4.0.4 and 4.0.6 versions. The comment in the 4.0.6 code which says "Note that it does not appear that the client data is actually used in this program." is clearly incorrect. The client data is definitely used. If you don't set it, the program crashes.

Can anyone shed some light on the goal of this change?

Regards,

Steve

1c1
< /* $Id: fax2tiff.c,v 1.23 2015-06-21 01:09:10 bfriesen Exp $ */
---
 > /* $Id: fax2tiff.c,v 1.24 2015-08-23 15:40:45 bfriesen Exp $ */
74a75,88
 > /*
 > Struct to carry client data. Note that it does not appear that the
client
 > data is actually used in this program.
 > */
 > typedef struct _FAX_Client_Data
 > {
 > #if defined(_WIN32) && defined(USE_WIN32_FILEIO)
 > intptr_t fh; /* Operating system file handle */
 > #else

 >         int fd;      /* Integer file descriptor */

 > #endif
 >
 > } FAX_Client_Data;
 >
79a94
 > FAX_Client_Data client_data;
270c285
< TIFFSetClientdata(faxTIFF,
(thandle_t)_get_osfhandle(fileno(in)));
---
 > client_data.fh = _get_osfhandle(fileno(in));
272c287
< TIFFSetClientdata(faxTIFF, (thandle_t)fileno(in));
---
 > client_data.fd = fileno(in);
273a289
 > TIFFSetClientdata(faxTIFF, (thandle_t) &client_data);