summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorMarti Maria <marti.maria@littlecms.com>2021-04-27 17:39:38 +0200
committerMarti Maria <marti.maria@littlecms.com>2021-04-27 17:39:38 +0200
commit807809d7dd9b09c0380b71d5d5ebee3c1439ca99 (patch)
tree3de42bd33fa1ddcbb41b3c3779fffb4820276cdc /utils
parentb423949ac9abcfd4009606856eba39217b3bd9b2 (diff)
downloadlcms2-807809d7dd9b09c0380b71d5d5ebee3c1439ca99.tar.gz
update tifficc sample
detect some corrupted TIFF files add a check for broken uint16 types
Diffstat (limited to 'utils')
-rw-r--r--utils/tificc/tificc.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/utils/tificc/tificc.c b/utils/tificc/tificc.c
index ddb77b5..c05bbc7 100644
--- a/utils/tificc/tificc.c
+++ b/utils/tificc/tificc.c
@@ -29,6 +29,14 @@
#include "tiffio.h"
#include "utils.h"
+// Fix broken libtiff 4.3.0, thanks to Bob Friesenhahn for uncovering this
+
+#if defined(HAVE_STDINT_H) && (TIFFLIB_VERSION >= 20201219)
+# undef uint16
+# define uint16 uint16_t
+# undef uint32
+# define uint32 uint32_t
+#endif /* TIFFLIB_VERSION */
// Flags
@@ -304,6 +312,8 @@ cmsUInt32Number GetInputPixelType(TIFF *Bank)
case PHOTOMETRIC_RGB:
pt = PT_RGB;
+ if (ColorChannels < 3)
+ FatalError("Sorry, RGB needs at least 3 samples per pixel");
break;
@@ -312,7 +322,6 @@ cmsUInt32Number GetInputPixelType(TIFF *Bank)
break;
case PHOTOMETRIC_SEPARATED:
-
pt = PixelTypeFromChanCount(ColorChannels);
break;
@@ -409,6 +418,9 @@ int TileBasedXform(cmsHTRANSFORM hXForm, TIFF* in, TIFF* out, int nPlanes)
BufferIn + (j*BufSizeIn), BufSizeIn) < 0) goto cleanup;
}
+ if (PixelCount < 0)
+ FatalError("TIFF is corrupted");
+
cmsDoTransform(hXForm, BufferIn, BufferOut, PixelCount);
for (j=0; j < nPlanes; j++) {
@@ -477,6 +489,9 @@ int StripBasedXform(cmsHTRANSFORM hXForm, TIFF* in, TIFF* out, int nPlanes)
PixelCount = (int) sw * (iml < sl ? iml : sl);
iml -= sl;
+ if (PixelCount < 0)
+ FatalError("TIFF is corrupted");
+
cmsDoTransform(hXForm, BufferIn, BufferOut, PixelCount);
for (j=0; j < nPlanes; j++) {