diff options
author | erouault <erouault> | 2017-09-07 14:02:52 +0000 |
---|---|---|
committer | erouault <erouault> | 2017-09-07 14:02:52 +0000 |
commit | ec22ba0f86313d4703bf60b82b5f9b88e4245ae0 (patch) | |
tree | 5e07ca0aa807f134e42fb79b73caa2b862ef5fa9 | |
parent | 62590f8e8cc7ce7010d4ed6395beee77f083dd0a (diff) | |
download | libtiff-ec22ba0f86313d4703bf60b82b5f9b88e4245ae0.tar.gz |
* libtiff/tiffiop.h, tif_aux.c: redirect SeekOK() macro to a _TIFFSeekoK()
function that checks if the offset is not bigger than INT64_MAX, so as
to avoid a -1 error return code of TIFFSeekFile() to match a required
seek to UINT64_MAX/-1.
Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2726
Adapted from proposal by Nicolas Ruff.
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | libtiff/tif_aux.c | 9 | ||||
-rw-r--r-- | libtiff/tiffiop.h | 6 |
3 files changed, 20 insertions, 4 deletions
@@ -1,3 +1,12 @@ +2017-09-27 Even Rouault <even.rouault at spatialys.com> + + * libtiff/tiffiop.h, tif_aux.c: redirect SeekOK() macro to a _TIFFSeekoK() + function that checks if the offset is not bigger than INT64_MAX, so as + to avoid a -1 error return code of TIFFSeekFile() to match a required + seek to UINT64_MAX/-1. + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2726 + Adapted from proposal by Nicolas Ruff. + 2017-08-29 Even Rouault <even.rouault at spatialys.com> * libtiff/tif_jpeg.c: accept reading the last strip of a JPEG compressed diff --git a/libtiff/tif_aux.c b/libtiff/tif_aux.c index 3d35ba92..7f6721b9 100644 --- a/libtiff/tif_aux.c +++ b/libtiff/tif_aux.c @@ -1,4 +1,4 @@ -/* $Id: tif_aux.c,v 1.29 2016-11-11 20:45:53 erouault Exp $ */ +/* $Id: tif_aux.c,v 1.30 2017-09-07 14:02:52 erouault Exp $ */ /* * Copyright (c) 1991-1997 Sam Leffler @@ -359,6 +359,13 @@ _TIFFUInt64ToDouble(uint64 ui64) } } +int _TIFFSeekOK(TIFF* tif, toff_t off) +{ + /* Huge offsets, expecially -1 / UINT64_MAX, can cause issues */ + /* See http://bugzilla.maptools.org/show_bug.cgi?id=2726 */ + return off <= (~(uint64)0)/2 && TIFFSeekFile(tif,off,SEEK_SET)==off; +} + /* vim: set ts=8 sts=8 sw=8 noet: */ /* * Local Variables: diff --git a/libtiff/tiffiop.h b/libtiff/tiffiop.h index 87c7cb08..daa291c0 100644 --- a/libtiff/tiffiop.h +++ b/libtiff/tiffiop.h @@ -1,4 +1,4 @@ -/* $Id: tiffiop.h,v 1.94 2017-07-04 13:28:42 erouault Exp $ */ +/* $Id: tiffiop.h,v 1.95 2017-09-07 14:02:52 erouault Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -238,8 +238,7 @@ struct tiff { (TIFFReadFile((tif),(buf),(size))==(size)) #endif #ifndef SeekOK -#define SeekOK(tif, off) \ - (TIFFSeekFile((tif),(off),SEEK_SET)==(off)) +#define SeekOK(tif, off) _TIFFSeekOK(tif, off) #endif #ifndef WriteOK #define WriteOK(tif, buf, size) \ @@ -384,6 +383,7 @@ extern tmsize_t _TIFFReadTileAndAllocBuffer(TIFF* tif, void **buf, tmsize_t bufsizetoalloc, uint32 x, uint32 y, uint32 z, uint16 s); +extern int _TIFFSeekOK(TIFF* tif, toff_t off); extern int TIFFInitDumpMode(TIFF*, int); #ifdef PACKBITS_SUPPORT |