Commit 1cb6c46b authored by Bob Friesenhahn's avatar Bob Friesenhahn

fax2tiff: Pass the FAX_Client_Data struct as client data

parent f258b802
2017-10-29 Bob Friesenhahn <[email protected]>
* tools/fax2tiff.c (_FAX_Client_Data): Pass FAX_Client_Data as the
client data. This client data is not used at all at the moment,
but it makes the most sense. Issue that the value of
client_data.fd was passed where a pointer is expected was reported
via email by Gerald Schade on Sun, 29 Oct 2017.
  • can you explain where a pointer is expected ?

    a thandle_t is expected. under unix it is used as an int in the union :

    typedef union fd_as_handle_union
    {
    	int fd;
    	thandle_t h;
    } fd_as_handle_union_t;
    
    static tmsize_t
    _tiffReadProc(thandle_t fd, void* buf, tmsize_t size)
    {
    	fd_as_handle_union_t fdh;
    [...]
    	fdh.h = fd;
    [...]
                  count=read(fdh.fd, buf_offset, (TIFFIOSize_t) io_size);
  • Thomas Bernard started a new discussion on ChangeLog:

      • tools/fax2tiff.c (_FAX_Client_Data): Pass FAX_Client_Data as the
    • client data. This client data is not used at all at the moment,
    • but it makes the most sense. Issue that the value of
    • client_data.fd was passed where a pointer is expected was reported
    • via email by Gerald Schade on Sun, 29 Oct 2017.

    can you explain where a pointer is expected ?

    It is needed to in order to pass an arbitrary pointer to user-provided context when TIFFClientOpen() is used.

    The current declarations of thandle_t appear to be problematic since they are made dependent on Microsoft Windows declarations, apparently assuming that tif_win32.c is the only user. If these Microsoft Windows declarations are not at least the size of a 'void*' then problems will result in portable code which assumes that a pointer can be passed here.

    Bob

  • DECLARE_HANDLE() does in fact define the type as a pointer, so I don't see what you mean. Of course thandle_t is the size of a pointer, but that doesn't mean it has to be used a pointer...

Please register or sign in to reply
2017-10-23 Even Rouault <even.rouault at spatialys.com>
* libtiff/tif_getimage.c: avoid floating point division by zero in
......
......@@ -222,8 +222,8 @@ am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/libtiff-4.pc.in \
$(top_srcdir)/config/missing \
$(top_srcdir)/config/mkinstalldirs ChangeLog README TODO \
config/compile config/config.guess config/config.sub \
config/install-sh config/ltmain.sh config/missing \
config/mkinstalldirs
config/depcomp config/install-sh config/ltmain.sh \
config/missing config/mkinstalldirs
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
......@@ -405,7 +405,6 @@ pdfdir = @[email protected]
prefix = @[email protected]
program_transform_name = @[email protected]
psdir = @[email protected]
runstatedir = @[email protected]
sbindir = @[email protected]
sharedstatedir = @[email protected]
srcdir = @[email protected]
......
......@@ -349,7 +349,6 @@ pdfdir = @[email protected]
prefix = @[email protected]
program_transform_name = @[email protected]
psdir = @[email protected]
runstatedir = @[email protected]
sbindir = @[email protected]
sharedstatedir = @[email protected]
srcdir = @[email protected]
......
......@@ -782,7 +782,6 @@ infodir
docdir
oldincludedir
includedir
runstatedir
localstatedir
sharedstatedir
sysconfdir
......@@ -907,7 +906,6 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
......@@ -1160,15 +1158,6 @@ do
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
-runstatedir | --runstatedir | --runstatedi | --runstated \
| --runstate | --runstat | --runsta | --runst | --runs \
| --run | --ru | --r)
ac_prev=runstatedir ;;
-runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
| --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
| --run=* | --ru=* | --r=*)
runstatedir=$ac_optarg ;;
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
......@@ -1306,7 +1295,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
libdir localedir mandir runstatedir
libdir localedir mandir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
......@@ -1459,7 +1448,6 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
......@@ -18397,7 +18385,7 @@ else
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
......@@ -18443,7 +18431,7 @@ else
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
......@@ -18467,7 +18455,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
......@@ -18512,7 +18500,7 @@ else
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
......@@ -18536,7 +18524,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
......
......@@ -348,7 +348,6 @@ pdfdir = @[email protected]
prefix = @[email protected]
program_transform_name = @[email protected]
psdir = @[email protected]
runstatedir = @[email protected]
sbindir = @[email protected]
sharedstatedir = @[email protected]
srcdir = @[email protected]
......
......@@ -339,7 +339,6 @@ pdfdir = @[email protected]
prefix = @[email protected]
program_transform_name = @[email protected]
psdir = @[email protected]
runstatedir = @[email protected]
sbindir = @[email protected]
sharedstatedir = @[email protected]
srcdir = @[email protected]
......
......@@ -392,7 +392,6 @@ pdfdir = @[email protected]
prefix = @[email protected]
program_transform_name = @[email protected]
psdir = @[email protected]
runstatedir = @[email protected]
sbindir = @[email protected]
sharedstatedir = @[email protected]
srcdir = @[email protected]
......
......@@ -291,7 +291,6 @@ pdfdir = @[email protected]
prefix = @[email protected]
program_transform_name = @[email protected]
psdir = @[email protected]
runstatedir = @[email protected]
sbindir = @[email protected]
sharedstatedir = @[email protected]
srcdir = @[email protected]
......
......@@ -338,7 +338,6 @@ pdfdir = @[email protected]
prefix = @[email protected]
program_transform_name = @[email protected]
psdir = @[email protected]
runstatedir = @[email protected]
sbindir = @[email protected]
sharedstatedir = @[email protected]
srcdir = @[email protected]
......
......@@ -288,7 +288,6 @@ pdfdir = @[email protected]
prefix = @[email protected]
program_transform_name = @[email protected]
psdir = @[email protected]
runstatedir = @[email protected]
sbindir = @[email protected]
sharedstatedir = @[email protected]
srcdir = @[email protected]
......
......@@ -288,7 +288,6 @@ pdfdir = @[email protected]
prefix = @[email protected]
program_transform_name = @[email protected]
psdir = @[email protected]
runstatedir = @[email protected]
sbindir = @[email protected]
sharedstatedir = @[email protected]
srcdir = @[email protected]
......
......@@ -288,7 +288,6 @@ pdfdir = @[email protected]
prefix = @[email protected]
program_transform_name = @[email protected]
psdir = @[email protected]
runstatedir = @[email protected]
sbindir = @[email protected]
sharedstatedir = @[email protected]
srcdir = @[email protected]
......
......@@ -288,7 +288,6 @@ pdfdir = @[email protected]
prefix = @[email protected]
program_transform_name = @[email protected]
psdir = @[email protected]
runstatedir = @[email protected]
sbindir = @[email protected]
sharedstatedir = @[email protected]
srcdir = @[email protected]
......
......@@ -288,7 +288,6 @@ pdfdir = @[email protected]
prefix = @[email protected]
program_transform_name = @[email protected]
psdir = @[email protected]
runstatedir = @[email protected]
sbindir = @[email protected]
sharedstatedir = @[email protected]
srcdir = @[email protected]
......
......@@ -288,7 +288,6 @@ pdfdir = @[email protected]
prefix = @[email protected]
program_transform_name = @[email protected]
psdir = @[email protected]
runstatedir = @[email protected]
sbindir = @[email protected]
sharedstatedir = @[email protected]
srcdir = @[email protected]
......
......@@ -380,7 +380,6 @@ pdfdir = @[email protected]
prefix = @[email protected]
program_transform_name = @[email protected]
psdir = @[email protected]
runstatedir = @[email protected]
sbindir = @[email protected]
sharedstatedir = @[email protected]
srcdir = @[email protected]
......
......@@ -319,7 +319,6 @@ pdfdir = @[email protected]
prefix = @[email protected]
program_transform_name = @[email protected]
psdir = @[email protected]
runstatedir = @[email protected]
sbindir = @[email protected]
sharedstatedir = @[email protected]
srcdir = @[email protected]
......
......@@ -319,7 +319,6 @@ pdfdir = @[email protected]
prefix = @[email protected]
program_transform_name = @[email protected]
psdir = @[email protected]
runstatedir = @[email protected]
sbindir = @[email protected]
sharedstatedir = @[email protected]
srcdir = @[email protected]
......
......@@ -440,7 +440,6 @@ pdfdir = @[email protected]
prefix = @[email protected]
program_transform_name = @[email protected]
psdir = @[email protected]
runstatedir = @[email protected]
sbindir = @[email protected]
sharedstatedir = @[email protected]
srcdir = @[email protected]
......
......@@ -320,7 +320,6 @@ pdfdir = @[email protected]
prefix = @[email protected]
program_transform_name = @[email protected]
psdir = @[email protected]
runstatedir = @[email protected]
sbindir = @[email protected]
sharedstatedir = @[email protected]
srcdir = @[email protected]
......
......@@ -338,7 +338,6 @@ pdfdir = @[email protected]
prefix = @[email protected]
program_transform_name = @[email protected]
psdir = @[email protected]
runstatedir = @[email protected]
sbindir = @[email protected]
sharedstatedir = @[email protected]
srcdir = @[email protected]
......
......@@ -620,7 +620,6 @@ pdfdir = @[email protected]
prefix = @[email protected]
program_transform_name = @[email protected]
psdir = @[email protected]
runstatedir = @[email protected]
sbindir = @[email protected]
sharedstatedir = @[email protected]
srcdir = @[email protected]
......
......@@ -427,7 +427,6 @@ pdfdir = @[email protected]
prefix = @[email protected]
program_transform_name = @[email protected]
psdir = @[email protected]
runstatedir = @[email protected]
sbindir = @[email protected]
sharedstatedir = @[email protected]
srcdir = @[email protected]
......
/* $Id: fax2tiff.c,v 1.27 2017-04-27 19:50:01 erouault Exp $ */
/* $Id: fax2tiff.c,v 1.28 2017-10-29 18:28:45 bfriesen Exp $ */
/*
* Copyright (c) 1990-1997 Sam Leffler
......@@ -283,11 +283,10 @@ main(int argc, char* argv[])
}
#if defined(_WIN32) && defined(USE_WIN32_FILEIO)
client_data.fh = _get_osfhandle(fileno(in));
TIFFSetClientdata(faxTIFF, (thandle_t) client_data.fh);
#else
client_data.fd = fileno(in);
TIFFSetClientdata(faxTIFF, (thandle_t) client_data.fd);
#endif
TIFFSetClientdata(faxTIFF, (thandle_t) &client_data);
TIFFSetFileName(faxTIFF, (const char*)argv[optind]);
TIFFSetField(out, TIFFTAG_IMAGEWIDTH, xsize);
TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 1);
......
  • @bobfriesenhahn this commit makes the file I/O not working for the fax2tiff program. At least on linux/unix it is not working. The functions in tif_unix.c should get a file descriptor to work but they now get a pointer to the file descriptor.

    The comment in the ChangeLog describes the opposite, that a fd was passed where a pointer was expected, so it seems like different functions that use the client data expect different types.

  • @bobfriesenhahn this commit makes the file I/O not working for the fax2tiff program. At least on linux/unix it is not working. The functions in tif_unix.c should get a file descriptor to work but they now get a pointer to the file descriptor.

    The comment in the ChangeLog describes the opposite, that a fd was passed where a pointer was expected, so it seems like different functions that use the client data expect different types.

    You must be talking about this hunk in tools/fax2tiff.c:

    /* 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;

    Are you definining _WIN32 and USE_WIN32_FILEIO under Linux?

    Bob

  • No, I am not defining _WIN32 and USE_WIN32_FILEIO.

    The problem with the change is that TIFFSetClientdata() is now called with a pointer (FAX_Client_Data*). Previously it was called with a file descriptor (int). This change of course affects any code that uses clientdata, such as the file I/O operations.

    The functions for file I/O expects a file descriptor in clientdata, not a pointer. Now all file operations returns 'Bad file descriptor' on Linux. See TIFFGetFileSize() and TIFFReadFile() macros which calls _tiffSizeProc() and _tiffReadProc() in tif_unix.c.

    Reverting this commit makes everything work again.

    Lars

  • mentioned in merge request !55 (merged)

    Toggle commit list
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment