Commit 85d6b767 authored by Alexandre Julliard's avatar Alexandre Julliard

tiff: Import upstream release 4.5.1.

parent 49e12082
...@@ -51,8 +51,7 @@ void TIFFCleanup(TIFF *tif) ...@@ -51,8 +51,7 @@ void TIFFCleanup(TIFF *tif)
(*tif->tif_cleanup)(tif); (*tif->tif_cleanup)(tif);
TIFFFreeDirectory(tif); TIFFFreeDirectory(tif);
TIFFHashSetDestroy(tif->tif_map_dir_offset_to_number); _TIFFCleanupIFDOffsetAndNumberMaps(tif);
TIFFHashSetDestroy(tif->tif_map_dir_number_to_offset);
/* /*
* Clean up client info links. * Clean up client info links.
...@@ -115,6 +114,24 @@ void TIFFCleanup(TIFF *tif) ...@@ -115,6 +114,24 @@ void TIFFCleanup(TIFF *tif)
} }
/************************************************************************/ /************************************************************************/
/* _TIFFCleanupIFDOffsetAndNumberMaps() */
/************************************************************************/
void _TIFFCleanupIFDOffsetAndNumberMaps(TIFF *tif)
{
if (tif->tif_map_dir_offset_to_number)
{
TIFFHashSetDestroy(tif->tif_map_dir_offset_to_number);
tif->tif_map_dir_offset_to_number = NULL;
}
if (tif->tif_map_dir_number_to_offset)
{
TIFFHashSetDestroy(tif->tif_map_dir_number_to_offset);
tif->tif_map_dir_number_to_offset = NULL;
}
}
/************************************************************************/
/* TIFFClose() */ /* TIFFClose() */
/************************************************************************/ /************************************************************************/
...@@ -130,9 +147,12 @@ void TIFFCleanup(TIFF *tif) ...@@ -130,9 +147,12 @@ void TIFFCleanup(TIFF *tif)
void TIFFClose(TIFF *tif) void TIFFClose(TIFF *tif)
{ {
TIFFCloseProc closeproc = tif->tif_closeproc; if (tif != NULL)
thandle_t fd = tif->tif_clientdata; {
TIFFCloseProc closeproc = tif->tif_closeproc;
thandle_t fd = tif->tif_clientdata;
TIFFCleanup(tif); TIFFCleanup(tif);
(void)(*closeproc)(fd); (void)(*closeproc)(fd);
}
} }
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
#define PACKAGE_NAME "LibTIFF Software" #define PACKAGE_NAME "LibTIFF Software"
/* Define to the full name and version of this package. */ /* Define to the full name and version of this package. */
#define PACKAGE_STRING "LibTIFF Software 4.5.0" #define PACKAGE_STRING "LibTIFF Software 4.5.1"
/* Define to the one symbol short name of this package. */ /* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "tiff" #define PACKAGE_TARNAME "tiff"
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
#define PACKAGE_URL "" #define PACKAGE_URL ""
/* Define to the version of this package. */ /* Define to the version of this package. */
#define PACKAGE_VERSION "4.5.0" #define PACKAGE_VERSION "4.5.1"
/* The size of `size_t', as computed by sizeof. */ /* The size of `size_t', as computed by sizeof. */
#define SIZEOF_SIZE_T 4 #define SIZEOF_SIZE_T 4
...@@ -120,7 +120,7 @@ ...@@ -120,7 +120,7 @@
#define USE_WIN32_FILEIO 1 #define USE_WIN32_FILEIO 1
/* Version number of package */ /* Version number of package */
#define VERSION "4.5.0" #define VERSION "4.5.1"
/* Support webp compression */ /* Support webp compression */
/* #undef WEBP_SUPPORT */ /* #undef WEBP_SUPPORT */
......
...@@ -192,11 +192,11 @@ static int setExtraSamples(TIFF *tif, va_list ap, uint32_t *v) ...@@ -192,11 +192,11 @@ static int setExtraSamples(TIFF *tif, va_list ap, uint32_t *v)
static uint16_t countInkNamesString(TIFF *tif, uint32_t slen, const char *s) static uint16_t countInkNamesString(TIFF *tif, uint32_t slen, const char *s)
{ {
uint16_t i = 0; uint16_t i = 0;
const char *ep = s + slen;
const char *cp = s;
if (slen > 0) if (slen > 0)
{ {
const char *ep = s + slen;
const char *cp = s;
do do
{ {
for (; cp < ep && *cp != '\0'; cp++) for (; cp < ep && *cp != '\0'; cp++)
...@@ -1621,7 +1621,7 @@ void TIFFFreeDirectory(TIFF *tif) ...@@ -1621,7 +1621,7 @@ void TIFFFreeDirectory(TIFF *tif)
TIFFDirectory *td = &tif->tif_dir; TIFFDirectory *td = &tif->tif_dir;
int i; int i;
_TIFFmemset(td->td_fieldsset, 0, FIELD_SETLONGS); _TIFFmemset(td->td_fieldsset, 0, sizeof(td->td_fieldsset));
CleanupField(td_sminsamplevalue); CleanupField(td_sminsamplevalue);
CleanupField(td_smaxsamplevalue); CleanupField(td_smaxsamplevalue);
CleanupField(td_colormap[0]); CleanupField(td_colormap[0]);
...@@ -1702,6 +1702,12 @@ int TIFFCreateCustomDirectory(TIFF *tif, const TIFFFieldArray *infoarray) ...@@ -1702,6 +1702,12 @@ int TIFFCreateCustomDirectory(TIFF *tif, const TIFFFieldArray *infoarray)
tif->tif_curoff = 0; tif->tif_curoff = 0;
tif->tif_row = (uint32_t)-1; tif->tif_row = (uint32_t)-1;
tif->tif_curstrip = (uint32_t)-1; tif->tif_curstrip = (uint32_t)-1;
/* invalidate directory index */
tif->tif_curdir = TIFF_NON_EXISTENT_DIR_NUMBER;
/* invalidate IFD loop lists */
_TIFFCleanupIFDOffsetAndNumberMaps(tif);
/* To be able to return from SubIFD or custom-IFD to main-IFD */
tif->tif_setdirectory_force_absolute = TRUE;
return 0; return 0;
} }
...@@ -2022,29 +2028,78 @@ tdir_t TIFFNumberOfDirectories(TIFF *tif) ...@@ -2022,29 +2028,78 @@ tdir_t TIFFNumberOfDirectories(TIFF *tif)
int TIFFSetDirectory(TIFF *tif, tdir_t dirn) int TIFFSetDirectory(TIFF *tif, tdir_t dirn)
{ {
uint64_t nextdiroff; uint64_t nextdiroff;
tdir_t nextdirnum; tdir_t nextdirnum = 0;
tdir_t n; tdir_t n;
if (!(tif->tif_flags & TIFF_BIGTIFF)) if (tif->tif_setdirectory_force_absolute)
nextdiroff = tif->tif_header.classic.tiff_diroff; {
/* tif_setdirectory_force_absolute=1 will force parsing the main IFD
* chain from the beginning, thus IFD directory list needs to be cleared
* from possible SubIFD offsets.
*/
_TIFFCleanupIFDOffsetAndNumberMaps(tif); /* invalidate IFD loop lists */
}
/* Even faster path, if offset is available within IFD loop hash list. */
if (!tif->tif_setdirectory_force_absolute &&
_TIFFGetOffsetFromDirNumber(tif, dirn, &nextdiroff))
{
/* Set parameters for following TIFFReadDirectory() below. */
tif->tif_nextdiroff = nextdiroff;
tif->tif_curdir = dirn;
/* Reset to relative stepping */
tif->tif_setdirectory_force_absolute = FALSE;
}
else else
nextdiroff = tif->tif_header.big.tiff_diroff; {
nextdirnum = 0;
for (n = dirn; n > 0 && nextdiroff != 0; n--) /* Fast path when we just advance relative to the current directory:
if (!TIFFAdvanceDirectory(tif, &nextdiroff, NULL, &nextdirnum)) * start at the current dir offset and continue to seek from there.
* Check special cases when relative is not allowed:
* - jump back from SubIFD or custom directory
* - right after TIFFWriteDirectory() jump back to that directory
* using TIFFSetDirectory() */
const int relative = (dirn >= tif->tif_curdir) &&
(tif->tif_diroff != 0) &&
!tif->tif_setdirectory_force_absolute;
if (relative)
{
nextdiroff = tif->tif_diroff;
dirn -= tif->tif_curdir;
nextdirnum = tif->tif_curdir;
}
else if (!(tif->tif_flags & TIFF_BIGTIFF))
nextdiroff = tif->tif_header.classic.tiff_diroff;
else
nextdiroff = tif->tif_header.big.tiff_diroff;
/* Reset to relative stepping */
tif->tif_setdirectory_force_absolute = FALSE;
for (n = dirn; n > 0 && nextdiroff != 0; n--)
if (!TIFFAdvanceDirectory(tif, &nextdiroff, NULL, &nextdirnum))
return (0);
/* If the n-th directory could not be reached (does not exist),
* return here without touching anything further. */
if (nextdiroff == 0 || n > 0)
return (0); return (0);
/* If the n-th directory could not be reached (does not exist),
* return here without touching anything further. */
if (nextdiroff == 0 || n > 0)
return (0);
tif->tif_nextdiroff = nextdiroff; tif->tif_nextdiroff = nextdiroff;
/*
* Set curdir to the actual directory index. The /* Set curdir to the actual directory index. */
* -1 is because TIFFReadDirectory will increment if (relative)
* tif_curdir after successfully reading the directory. tif->tif_curdir += dirn - n;
*/ else
tif->tif_curdir = (dirn - n) - 1; tif->tif_curdir = dirn - n;
}
/* The -1 decrement is because TIFFReadDirectory will increment
* tif_curdir after successfully reading the directory. */
if (tif->tif_curdir == 0)
tif->tif_curdir = TIFF_NON_EXISTENT_DIR_NUMBER;
else
tif->tif_curdir--;
return (TIFFReadDirectory(tif)); return (TIFFReadDirectory(tif));
} }
...@@ -2088,8 +2143,8 @@ int TIFFSetSubDirectory(TIFF *tif, uint64_t diroff) ...@@ -2088,8 +2143,8 @@ int TIFFSetSubDirectory(TIFF *tif, uint64_t diroff)
tif->tif_nextdiroff = diroff; tif->tif_nextdiroff = diroff;
retval = TIFFReadDirectory(tif); retval = TIFFReadDirectory(tif);
/* If failed, curdir was not incremented in TIFFReadDirectory(), so set it /* If failed, curdir was not incremented in TIFFReadDirectory(), so set it
* back. */ * back, but leave it for diroff==0. */
if (!retval) if (!retval && diroff != 0)
{ {
if (tif->tif_curdir == TIFF_NON_EXISTENT_DIR_NUMBER) if (tif->tif_curdir == TIFF_NON_EXISTENT_DIR_NUMBER)
tif->tif_curdir = 0; tif->tif_curdir = 0;
...@@ -2100,10 +2155,12 @@ int TIFFSetSubDirectory(TIFF *tif, uint64_t diroff) ...@@ -2100,10 +2155,12 @@ int TIFFSetSubDirectory(TIFF *tif, uint64_t diroff)
{ {
/* Reset IFD list to start new one for SubIFD chain and also start /* Reset IFD list to start new one for SubIFD chain and also start
* SubIFD chain with tif_curdir=0. */ * SubIFD chain with tif_curdir=0. */
tif->tif_dirnumber = 0; _TIFFCleanupIFDOffsetAndNumberMaps(tif); /* invalidate IFD loop lists */
tif->tif_curdir = 0; /* first directory of new chain */ tif->tif_curdir = 0; /* first directory of new chain */
/* add this offset to new IFD list */ /* add this offset to new IFD list */
_TIFFCheckDirNumberAndOffset(tif, tif->tif_curdir, diroff); _TIFFCheckDirNumberAndOffset(tif, tif->tif_curdir, diroff);
/* To be able to return from SubIFD or custom-IFD to main-IFD */
tif->tif_setdirectory_force_absolute = TRUE;
} }
return (retval); return (retval);
} }
...@@ -2139,6 +2196,13 @@ int TIFFUnlinkDirectory(TIFF *tif, tdir_t dirn) ...@@ -2139,6 +2196,13 @@ int TIFFUnlinkDirectory(TIFF *tif, tdir_t dirn)
"Can not unlink directory in read-only file"); "Can not unlink directory in read-only file");
return (0); return (0);
} }
if (dirn == 0)
{
TIFFErrorExtR(tif, module,
"For TIFFUnlinkDirectory() first directory starts with "
"number 1 and not 0");
return (0);
}
/* /*
* Go to the directory before the one we want * Go to the directory before the one we want
* to unlink and nab the offset of the link * to unlink and nab the offset of the link
...@@ -2201,6 +2265,17 @@ int TIFFUnlinkDirectory(TIFF *tif, tdir_t dirn) ...@@ -2201,6 +2265,17 @@ int TIFFUnlinkDirectory(TIFF *tif, tdir_t dirn)
return (0); return (0);
} }
} }
/* For dirn=1 (first directory) also update the libtiff internal
* base offset variables. */
if (dirn == 1)
{
if (!(tif->tif_flags & TIFF_BIGTIFF))
tif->tif_header.classic.tiff_diroff = (uint32_t)nextdir;
else
tif->tif_header.big.tiff_diroff = nextdir;
}
/* /*
* Leave directory state setup safely. We don't have * Leave directory state setup safely. We don't have
* facilities for doing inserting and removing directories, * facilities for doing inserting and removing directories,
...@@ -2227,5 +2302,7 @@ int TIFFUnlinkDirectory(TIFF *tif, tdir_t dirn) ...@@ -2227,5 +2302,7 @@ int TIFFUnlinkDirectory(TIFF *tif, tdir_t dirn)
tif->tif_curoff = 0; tif->tif_curoff = 0;
tif->tif_row = (uint32_t)-1; tif->tif_row = (uint32_t)-1;
tif->tif_curstrip = (uint32_t)-1; tif->tif_curstrip = (uint32_t)-1;
tif->tif_curdir = TIFF_NON_EXISTENT_DIR_NUMBER;
_TIFFCleanupIFDOffsetAndNumberMaps(tif); /* invalidate IFD loop lists */
return (1); return (1);
} }
...@@ -70,9 +70,9 @@ typedef struct ...@@ -70,9 +70,9 @@ typedef struct
*/ */
typedef struct typedef struct
{ {
#define FIELD_SETLONGS 4 #define FIELDSET_ITEMS 4
/* bit vector of fields that are set */ /* bit vector of fields that are set */
unsigned long td_fieldsset[FIELD_SETLONGS]; uint32_t td_fieldsset[FIELDSET_ITEMS];
uint32_t td_imagewidth, td_imagelength, td_imagedepth; uint32_t td_imagewidth, td_imagelength, td_imagedepth;
uint32_t td_tilewidth, td_tilelength, td_tiledepth; uint32_t td_tilewidth, td_tilelength, td_tiledepth;
...@@ -202,9 +202,9 @@ typedef struct ...@@ -202,9 +202,9 @@ typedef struct
*/ */
#define FIELD_PSEUDO 0 #define FIELD_PSEUDO 0
#define FIELD_LAST (32 * FIELD_SETLONGS - 1) #define FIELD_LAST (32 * FIELDSET_ITEMS - 1)
#define BITn(n) (((unsigned long)1L) << ((n)&0x1f)) #define BITn(n) (((uint32_t)1L) << ((n)&0x1f))
#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32]) #define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field)) #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
#define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field)) #define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
...@@ -329,6 +329,10 @@ extern "C" ...@@ -329,6 +329,10 @@ extern "C"
uint64_t diroff); uint64_t diroff);
extern int _TIFFGetDirNumberFromOffset(TIFF *tif, uint64_t diroff, extern int _TIFFGetDirNumberFromOffset(TIFF *tif, uint64_t diroff,
tdir_t *dirn); tdir_t *dirn);
extern int _TIFFGetOffsetFromDirNumber(TIFF *tif, tdir_t dirn,
uint64_t *diroff);
extern int _TIFFRemoveEntryFromDirectoryListByOffset(TIFF *tif,
uint64_t diroff);
#if defined(__cplusplus) #if defined(__cplusplus)
} }
......
...@@ -320,6 +320,7 @@ int TIFFRewriteDirectory(TIFF *tif) ...@@ -320,6 +320,7 @@ int TIFFRewriteDirectory(TIFF *tif)
* Find and zero the pointer to this directory, so that TIFFLinkDirectory * Find and zero the pointer to this directory, so that TIFFLinkDirectory
* will cause it to be added after this directories current pre-link. * will cause it to be added after this directories current pre-link.
*/ */
uint64_t torewritediroff = tif->tif_diroff;
if (!(tif->tif_flags & TIFF_BIGTIFF)) if (!(tif->tif_flags & TIFF_BIGTIFF))
{ {
...@@ -387,6 +388,8 @@ int TIFFRewriteDirectory(TIFF *tif) ...@@ -387,6 +388,8 @@ int TIFFRewriteDirectory(TIFF *tif)
nextdir = nextnextdir; nextdir = nextnextdir;
} }
} }
/* Remove skipped offset from IFD loop directory list. */
_TIFFRemoveEntryFromDirectoryListByOffset(tif, torewritediroff);
} }
else else
{ {
...@@ -456,6 +459,8 @@ int TIFFRewriteDirectory(TIFF *tif) ...@@ -456,6 +459,8 @@ int TIFFRewriteDirectory(TIFF *tif)
nextdir = nextnextdir; nextdir = nextnextdir;
} }
} }
/* Remove skipped offset from IFD loop directory list. */
_TIFFRemoveEntryFromDirectoryListByOffset(tif, torewritediroff);
} }
/* /*
...@@ -1114,7 +1119,12 @@ static int TIFFWriteDirectorySec(TIFF *tif, int isimage, int imagedone, ...@@ -1114,7 +1119,12 @@ static int TIFFWriteDirectorySec(TIFF *tif, int isimage, int imagedone,
if (tif->tif_dataoff & 1) if (tif->tif_dataoff & 1)
tif->tif_dataoff++; tif->tif_dataoff++;
if (isimage) if (isimage)
tif->tif_curdir++; {
if (tif->tif_curdir == TIFF_NON_EXISTENT_DIR_NUMBER)
tif->tif_curdir = 0;
else
tif->tif_curdir++;
}
} }
if (isimage) if (isimage)
{ {
......
...@@ -537,7 +537,7 @@ static int Fax3SetupState(TIFF *tif) ...@@ -537,7 +537,7 @@ static int Fax3SetupState(TIFF *tif)
TIFFroundup and TIFFSafeMultiply return zero on integer overflow TIFFroundup and TIFFSafeMultiply return zero on integer overflow
*/ */
dsp->runs = (uint32_t *)NULL; dsp->runs = (uint32_t *)NULL;
dsp->nruns = TIFFroundup_32(rowpixels, 32); dsp->nruns = TIFFroundup_32(rowpixels + 1, 32);
if (needsRefLine) if (needsRefLine)
{ {
dsp->nruns = TIFFSafeMultiply(uint32_t, dsp->nruns, 2); dsp->nruns = TIFFSafeMultiply(uint32_t, dsp->nruns, 2);
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
* DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "tif_config.h"
#include "tif_hash_set.h" #include "tif_hash_set.h"
#include <assert.h> #include <assert.h>
...@@ -161,7 +163,6 @@ TIFFHashSet *TIFFHashSetNew(TIFFHashSetHashFunc fnHashFunc, ...@@ -161,7 +163,6 @@ TIFFHashSet *TIFFHashSetNew(TIFFHashSetHashFunc fnHashFunc,
return set; return set;
} }
#ifdef notdef
/************************************************************************/ /************************************************************************/
/* TIFFHashSetSize() */ /* TIFFHashSetSize() */
/************************************************************************/ /************************************************************************/
...@@ -181,7 +182,6 @@ int TIFFHashSetSize(const TIFFHashSet *set) ...@@ -181,7 +182,6 @@ int TIFFHashSetSize(const TIFFHashSet *set)
assert(set != NULL); assert(set != NULL);
return set->nSize; return set->nSize;
} }
#endif
/************************************************************************/ /************************************************************************/
/* TIFFHashSetGetNewListElt() */ /* TIFFHashSetGetNewListElt() */
......
...@@ -71,11 +71,11 @@ extern "C" ...@@ -71,11 +71,11 @@ extern "C"
void TIFFHashSetDestroy(TIFFHashSet *set); void TIFFHashSetDestroy(TIFFHashSet *set);
int TIFFHashSetSize(const TIFFHashSet *set);
#ifdef notused #ifdef notused
void TIFFHashSetClear(TIFFHashSet *set); void TIFFHashSetClear(TIFFHashSet *set);
int TIFFHashSetSize(const TIFFHashSet *set);
/** TIFFHashSetIterEltFunc */ /** TIFFHashSetIterEltFunc */
typedef int (*TIFFHashSetIterEltFunc)(void *elt, void *user_data); typedef int (*TIFFHashSetIterEltFunc)(void *elt, void *user_data);
......
...@@ -953,6 +953,13 @@ static ...@@ -953,6 +953,13 @@ static
{ {
register int vi, ui; register int vi, ui;
/* check for NaN */
if (u != u || v != v)
{
u = U_NEU;
v = V_NEU;
}
if (v < UV_VSTART) if (v < UV_VSTART)
return oog_encode(u, v); return oog_encode(u, v);
vi = tiff_itrunc((v - UV_VSTART) * (1. / UV_SQSIZ), em); vi = tiff_itrunc((v - UV_VSTART) * (1. / UV_SQSIZ), em);
......
...@@ -423,6 +423,10 @@ static int LZWDecode(TIFF *tif, uint8_t *op0, tmsize_t occ0, uint16_t s) ...@@ -423,6 +423,10 @@ static int LZWDecode(TIFF *tif, uint8_t *op0, tmsize_t occ0, uint16_t s)
if (sp->read_error) if (sp->read_error)
{ {
TIFFErrorExtR(tif, module,
"LZWDecode: Scanline %" PRIu32 " cannot be read due to "
"previous error",
tif->tif_row);
return 0; return 0;
} }
...@@ -742,6 +746,7 @@ after_loop: ...@@ -742,6 +746,7 @@ after_loop:
return (1); return (1);
no_eoi: no_eoi:
sp->read_error = 1;
TIFFErrorExtR(tif, module, TIFFErrorExtR(tif, module,
"LZWDecode: Strip %" PRIu32 " not terminated with EOI code", "LZWDecode: Strip %" PRIu32 " not terminated with EOI code",
tif->tif_curstrip); tif->tif_curstrip);
......
...@@ -365,8 +365,12 @@ TIFF *TIFFClientOpenExt(const char *name, const char *mode, ...@@ -365,8 +365,12 @@ TIFF *TIFFClientOpenExt(const char *name, const char *mode,
(tif->tif_flags & ~TIFF_FILLORDER) | FILLORDER_LSB2MSB; (tif->tif_flags & ~TIFF_FILLORDER) | FILLORDER_LSB2MSB;
break; break;
case 'H': case 'H':
TIFFWarningExtR(tif, name,
"H(ost) mode is deprecated. Since "
"libtiff 4.5.1, it is an alias of 'B' / "
"FILLORDER_MSB2LSB.");
tif->tif_flags = tif->tif_flags =
(tif->tif_flags & ~TIFF_FILLORDER) | HOST_FILLORDER; (tif->tif_flags & ~TIFF_FILLORDER) | FILLORDER_MSB2LSB;
break; break;
case 'M': case 'M':
if (m == O_RDONLY) if (m == O_RDONLY)
...@@ -485,7 +489,7 @@ TIFF *TIFFClientOpenExt(const char *name, const char *mode, ...@@ -485,7 +489,7 @@ TIFF *TIFFClientOpenExt(const char *name, const char *mode,
goto bad; goto bad;
tif->tif_diroff = 0; tif->tif_diroff = 0;
tif->tif_lastdiroff = 0; tif->tif_lastdiroff = 0;
tif->tif_dirnumber = 0; tif->tif_setdirectory_force_absolute = FALSE;
return (tif); return (tif);
} }
/* /*
......
...@@ -274,7 +274,7 @@ TIFF *TIFFOpenExt(const char *name, const char *mode, TIFFOpenOptions *opts) ...@@ -274,7 +274,7 @@ TIFF *TIFFOpenExt(const char *name, const char *mode, TIFFOpenOptions *opts)
dwMode = OPEN_EXISTING; dwMode = OPEN_EXISTING;
break; break;
case O_RDWR: case O_RDWR:
dwMode = OPEN_ALWAYS; dwMode = OPEN_EXISTING;
break; break;
case O_RDWR | O_CREAT: case O_RDWR | O_CREAT:
dwMode = OPEN_ALWAYS; dwMode = OPEN_ALWAYS;
...@@ -332,7 +332,7 @@ TIFF *TIFFOpenWExt(const wchar_t *name, const char *mode, TIFFOpenOptions *opts) ...@@ -332,7 +332,7 @@ TIFF *TIFFOpenWExt(const wchar_t *name, const char *mode, TIFFOpenOptions *opts)
dwMode = OPEN_EXISTING; dwMode = OPEN_EXISTING;
break; break;
case O_RDWR: case O_RDWR:
dwMode = OPEN_ALWAYS; dwMode = OPEN_EXISTING;
break; break;
case O_RDWR | O_CREAT: case O_RDWR | O_CREAT:
dwMode = OPEN_ALWAYS; dwMode = OPEN_ALWAYS;
......
...@@ -48,9 +48,6 @@ ...@@ -48,9 +48,6 @@
machine */ machine */
#define HAVE_IEEEFP 1 #define HAVE_IEEEFP 1
/* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */
#define HOST_FILLORDER FILLORDER_LSB2MSB
/* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian /* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian
(Intel) */ (Intel) */
#define HOST_BIGENDIAN 0 #define HOST_BIGENDIAN 0
......
...@@ -263,6 +263,12 @@ typedef struct ...@@ -263,6 +263,12 @@ typedef struct
TIFFInitMethod init; TIFFInitMethod init;
} TIFFCodec; } TIFFCodec;
typedef struct
{
uint32_t uNum;
uint32_t uDenom;
} TIFFRational_t;
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
......
...@@ -143,15 +143,14 @@ struct tiff ...@@ -143,15 +143,14 @@ struct tiff
#define TIFF_CHOPPEDUPARRAYS \ #define TIFF_CHOPPEDUPARRAYS \
0x4000000U /* set when allocChoppedUpStripArrays() has modified strip \ 0x4000000U /* set when allocChoppedUpStripArrays() has modified strip \
array */ array */
uint64_t tif_diroff; /* file offset of current directory */ uint64_t tif_diroff; /* file offset of current directory */
uint64_t tif_nextdiroff; /* file offset of following directory */ uint64_t tif_nextdiroff; /* file offset of following directory */
uint64_t tif_lastdiroff; /* file offset of last directory written so far */ uint64_t tif_lastdiroff; /* file offset of last directory written so far */
uint64_t *tif_dirlistoff; /* list of offsets to already seen directories to
prevent IFD looping */
TIFFHashSet *tif_map_dir_offset_to_number; TIFFHashSet *tif_map_dir_offset_to_number;
TIFFHashSet *tif_map_dir_number_to_offset; TIFFHashSet *tif_map_dir_number_to_offset;
tdir_t tif_dirnumber; /* number of already seen directories */ int tif_setdirectory_force_absolute; /* switch between relative and absolute
TIFFDirectory tif_dir; /* internal rep of current directory */ stepping in TIFFSetDirectory() */
TIFFDirectory tif_dir; /* internal rep of current directory */
TIFFDirectory TIFFDirectory
tif_customdir; /* custom IFDs are separated from the main ones */ tif_customdir; /* custom IFDs are separated from the main ones */
union union
...@@ -444,6 +443,8 @@ extern "C" ...@@ -444,6 +443,8 @@ extern "C"
extern float _TIFFClampDoubleToFloat(double); extern float _TIFFClampDoubleToFloat(double);
extern uint32_t _TIFFClampDoubleToUInt32(double); extern uint32_t _TIFFClampDoubleToUInt32(double);
extern void _TIFFCleanupIFDOffsetAndNumberMaps(TIFF *tif);
extern tmsize_t _TIFFReadEncodedStripAndAllocBuffer(TIFF *tif, extern tmsize_t _TIFFReadEncodedStripAndAllocBuffer(TIFF *tif,
uint32_t strip, uint32_t strip,
void **buf, void **buf,
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
/* clang-format disabled because FindTIFF.cmake is very sensitive to the /* clang-format disabled because FindTIFF.cmake is very sensitive to the
* formatting of below line being a single line. * formatting of below line being a single line.
*/ */
#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.5.0\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc." #define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.5.1\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc."
/* /*
* This define can be used in code that requires * This define can be used in code that requires
* compilation-related definitions specific to a * compilation-related definitions specific to a
...@@ -11,12 +11,12 @@ ...@@ -11,12 +11,12 @@
* version checking should be done based on the * version checking should be done based on the
* string returned by TIFFGetVersion. * string returned by TIFFGetVersion.
*/ */
#define TIFFLIB_VERSION 20221213 #define TIFFLIB_VERSION 20230609
/* The following defines have been added in 4.5.0 */ /* The following defines have been added in 4.5.0 */
#define TIFFLIB_MAJOR_VERSION 4 #define TIFFLIB_MAJOR_VERSION 4
#define TIFFLIB_MINOR_VERSION 5 #define TIFFLIB_MINOR_VERSION 5
#define TIFFLIB_MICRO_VERSION 0 #define TIFFLIB_MICRO_VERSION 1
/* Macro added in 4.5.0. Returns TRUE if the current libtiff version is /* Macro added in 4.5.0. Returns TRUE if the current libtiff version is
* greater or equal to major.minor.micro * greater or equal to major.minor.micro
......
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