Blame SOURCES/libtiff-CVE-2019-14973.patch

4e3db6
From 218c3753fba788c78a9b5e515e884043f6e2ba28 Mon Sep 17 00:00:00 2001
4e3db6
From: Even Rouault <even.rouault@spatialys.com>
4e3db6
Date: Sat, 10 Aug 2019 18:25:03 +0200
4e3db6
Subject: [PATCH] Fix integer overflow in _TIFFCheckMalloc() and other
4e3db6
 implementation-defined behaviour (CVE-2019-14973)
4e3db6
4e3db6
_TIFFCheckMalloc()/_TIFFCheckRealloc() used a unsafe way to detect overflow
4e3db6
in the multiplication of nmemb and elem_size (which are of type tmsize_t, thus
4e3db6
signed), which was especially easily triggered on 32-bit builds (with recent
4e3db6
enough compilers that assume that signed multiplication cannot overflow, since
4e3db6
this is undefined behaviour by the C standard). The original issue which lead to
4e3db6
this fix was trigged from tif_fax3.c
4e3db6
4e3db6
There were also unsafe (implementation defied), and broken in practice on 64bit
4e3db6
builds, ways of checking that a uint64 fits of a (signed) tmsize_t by doing
4e3db6
(uint64)(tmsize_t)uint64_var != uint64_var comparisons. Those have no known
4e3db6
at that time exploits, but are better to fix in a more bullet-proof way.
4e3db6
Or similarly use of (int64)uint64_var <= 0.
4e3db6
---
4e3db6
 libtiff/tif_aux.c      | 49 +++++++++++++++++++++++++++++++++++++-----
4e3db6
 libtiff/tif_getimage.c |  6 ++----
4e3db6
 libtiff/tif_luv.c      |  8 +------
4e3db6
 libtiff/tif_pixarlog.c |  7 +-----
4e3db6
 libtiff/tif_read.c     | 38 +++++++++-----------------------
4e3db6
 libtiff/tif_strip.c    | 35 ++++--------------------------
4e3db6
 libtiff/tif_tile.c     | 27 +++--------------------
4e3db6
 libtiff/tiffiop.h      |  7 +++++-
4e3db6
 8 files changed, 71 insertions(+), 106 deletions(-)
4e3db6
4e3db6
diff --git a/libtiff/tif_aux.c b/libtiff/tif_aux.c
4e3db6
index 10b8d00..38a98b6 100644
4e3db6
--- a/libtiff/tif_aux.c
4e3db6
+++ b/libtiff/tif_aux.c
4e3db6
@@ -59,18 +59,57 @@ _TIFFMultiply64(TIFF* tif, uint64 first, uint64 second, const char* where)
4e3db6
 	return bytes;
4e3db6
 }
4e3db6
 
4e3db6
+tmsize_t
4e3db6
+_TIFFMultiplySSize(TIFF* tif, tmsize_t first, tmsize_t second, const char* where)
4e3db6
+{
4e3db6
+    if( first <= 0 || second <= 0 )
4e3db6
+    {
4e3db6
+        if( tif != NULL && where != NULL )
4e3db6
+        {
4e3db6
+            TIFFErrorExt(tif->tif_clientdata, where,
4e3db6
+                        "Invalid argument to _TIFFMultiplySSize() in %s", where);
4e3db6
+        }
4e3db6
+        return 0;
4e3db6
+    }
4e3db6
+
4e3db6
+    if( first > TIFF_TMSIZE_T_MAX / second )
4e3db6
+    {
4e3db6
+        if( tif != NULL && where != NULL )
4e3db6
+        {
4e3db6
+            TIFFErrorExt(tif->tif_clientdata, where,
4e3db6
+                        "Integer overflow in %s", where);
4e3db6
+        }
4e3db6
+        return 0;
4e3db6
+    }
4e3db6
+    return first * second;
4e3db6
+}
4e3db6
+
4e3db6
+tmsize_t _TIFFCastUInt64ToSSize(TIFF* tif, uint64 val, const char* module)
4e3db6
+{
4e3db6
+    if( val > (uint64)TIFF_TMSIZE_T_MAX )
4e3db6
+    {
4e3db6
+        if( tif != NULL && module != NULL )
4e3db6
+        {
4e3db6
+            TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
4e3db6
+        }
4e3db6
+        return 0;
4e3db6
+    }
4e3db6
+    return (tmsize_t)val;
4e3db6
+}
4e3db6
+
4e3db6
 void*
4e3db6
 _TIFFCheckRealloc(TIFF* tif, void* buffer,
4e3db6
 		  tmsize_t nmemb, tmsize_t elem_size, const char* what)
4e3db6
 {
4e3db6
 	void* cp = NULL;
4e3db6
-	tmsize_t bytes = nmemb * elem_size;
4e3db6
-
4e3db6
+        tmsize_t count = _TIFFMultiplySSize(tif, nmemb, elem_size, NULL);
4e3db6
 	/*
4e3db6
-	 * XXX: Check for integer overflow.
4e3db6
+	 * Check for integer overflow.
4e3db6
 	 */
4e3db6
-	if (nmemb && elem_size && bytes / elem_size == nmemb)
4e3db6
-		cp = _TIFFrealloc(buffer, bytes);
4e3db6
+	if (count != 0)
4e3db6
+	{
4e3db6
+		cp = _TIFFrealloc(buffer, count);
4e3db6
+	}
4e3db6
 
4e3db6
 	if (cp == NULL) {
4e3db6
 		TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
4e3db6
diff --git a/libtiff/tif_getimage.c b/libtiff/tif_getimage.c
4e3db6
index fc554cc..ec09fea 100644
4e3db6
--- a/libtiff/tif_getimage.c
4e3db6
+++ b/libtiff/tif_getimage.c
4e3db6
@@ -757,9 +757,8 @@ gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
4e3db6
 	uint32 leftmost_tw;
4e3db6
 
4e3db6
 	tilesize = TIFFTileSize(tif);  
4e3db6
-	bufsize = TIFFSafeMultiply(tmsize_t,alpha?4:3,tilesize);
4e3db6
+	bufsize = _TIFFMultiplySSize(tif, alpha?4:3,tilesize, "gtTileSeparate");
4e3db6
 	if (bufsize == 0) {
4e3db6
-		TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "Integer overflow in %s", "gtTileSeparate");
4e3db6
 		return (0);
4e3db6
 	}
4e3db6
 
4e3db6
@@ -1021,9 +1020,8 @@ gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
4e3db6
         uint16 colorchannels;
4e3db6
 
4e3db6
 	stripsize = TIFFStripSize(tif);  
4e3db6
-	bufsize = TIFFSafeMultiply(tmsize_t,alpha?4:3,stripsize);
4e3db6
+	bufsize = _TIFFMultiplySSize(tif,alpha?4:3,stripsize, "gtStripSeparate");
4e3db6
 	if (bufsize == 0) {
4e3db6
-		TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "Integer overflow in %s", "gtStripSeparate");
4e3db6
 		return (0);
4e3db6
 	}
4e3db6
 
4e3db6
diff --git a/libtiff/tif_luv.c b/libtiff/tif_luv.c
4e3db6
index 4b25244..c4cb73a 100644
4e3db6
--- a/libtiff/tif_luv.c
4e3db6
+++ b/libtiff/tif_luv.c
4e3db6
@@ -1264,16 +1264,10 @@ LogL16GuessDataFmt(TIFFDirectory *td)
4e3db6
 	return (SGILOGDATAFMT_UNKNOWN);
4e3db6
 }
4e3db6
 
4e3db6
-
4e3db6
-#define TIFF_SIZE_T_MAX ((size_t) ~ ((size_t)0))
4e3db6
-#define TIFF_TMSIZE_T_MAX (tmsize_t)(TIFF_SIZE_T_MAX >> 1)
4e3db6
-
4e3db6
 static tmsize_t
4e3db6
 multiply_ms(tmsize_t m1, tmsize_t m2)
4e3db6
 {
4e3db6
-        if( m1 == 0 || m2 > TIFF_TMSIZE_T_MAX / m1 )
4e3db6
-            return 0;
4e3db6
-        return m1 * m2;
4e3db6
+        return _TIFFMultiplySSize(NULL, m1, m2, NULL);
4e3db6
 }
4e3db6
 
4e3db6
 static int
4e3db6
diff --git a/libtiff/tif_pixarlog.c b/libtiff/tif_pixarlog.c
4e3db6
index 979858d..8e9eaa1 100644
4e3db6
--- a/libtiff/tif_pixarlog.c
4e3db6
+++ b/libtiff/tif_pixarlog.c
4e3db6
@@ -636,15 +636,10 @@ PixarLogGuessDataFmt(TIFFDirectory *td)
4e3db6
 	return guess;
4e3db6
 }
4e3db6
 
4e3db6
-#define TIFF_SIZE_T_MAX ((size_t) ~ ((size_t)0))
4e3db6
-#define TIFF_TMSIZE_T_MAX (tmsize_t)(TIFF_SIZE_T_MAX >> 1)
4e3db6
-
4e3db6
 static tmsize_t
4e3db6
 multiply_ms(tmsize_t m1, tmsize_t m2)
4e3db6
 {
4e3db6
-        if( m1 == 0 || m2 > TIFF_TMSIZE_T_MAX / m1 )
4e3db6
-            return 0;
4e3db6
-        return m1 * m2;
4e3db6
+        return _TIFFMultiplySSize(NULL, m1, m2, NULL);
4e3db6
 }
4e3db6
 
4e3db6
 static tmsize_t
4e3db6
diff --git a/libtiff/tif_read.c b/libtiff/tif_read.c
4e3db6
index 04100f4..9a0e6e9 100644
4e3db6
--- a/libtiff/tif_read.c
4e3db6
+++ b/libtiff/tif_read.c
4e3db6
@@ -31,9 +31,6 @@
4e3db6
 #include "tiffiop.h"
4e3db6
 #include <stdio.h>
4e3db6
 
4e3db6
-#define TIFF_SIZE_T_MAX ((size_t) ~ ((size_t)0))
4e3db6
-#define TIFF_TMSIZE_T_MAX (tmsize_t)(TIFF_SIZE_T_MAX >> 1)
4e3db6
-
4e3db6
 int TIFFFillStrip(TIFF* tif, uint32 strip);
4e3db6
 int TIFFFillTile(TIFF* tif, uint32 tile);
4e3db6
 static int TIFFStartStrip(TIFF* tif, uint32 strip);
4e3db6
@@ -51,6 +48,8 @@ TIFFReadRawTile1(TIFF* tif, uint32 tile, void* buf, tmsize_t size, const char* m
4e3db6
 #define THRESHOLD_MULTIPLIER 10
4e3db6
 #define MAX_THRESHOLD (THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * INITIAL_THRESHOLD)
4e3db6
 
4e3db6
+#define TIFF_INT64_MAX ((((int64)0x7FFFFFFF) << 32) | 0xFFFFFFFF)
4e3db6
+
4e3db6
 /* Read 'size' bytes in tif_rawdata buffer starting at offset 'rawdata_offset'
4e3db6
  * Returns 1 in case of success, 0 otherwise. */
4e3db6
 static int TIFFReadAndRealloc( TIFF* tif, tmsize_t size,
4e3db6
@@ -735,23 +734,8 @@ TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size)
4e3db6
 		return ((tmsize_t)(-1));
4e3db6
 	}
4e3db6
 	bytecount = td->td_stripbytecount[strip];
4e3db6
-	if ((int64)bytecount <= 0) {
4e3db6
-#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
4e3db6
-		TIFFErrorExt(tif->tif_clientdata, module,
4e3db6
-			     "%I64u: Invalid strip byte count, strip %lu",
4e3db6
-			     (unsigned __int64) bytecount,
4e3db6
-			     (unsigned long) strip);
4e3db6
-#else
4e3db6
-		TIFFErrorExt(tif->tif_clientdata, module,
4e3db6
-			     "%llu: Invalid strip byte count, strip %lu",
4e3db6
-			     (unsigned long long) bytecount,
4e3db6
-			     (unsigned long) strip);
4e3db6
-#endif
4e3db6
-		return ((tmsize_t)(-1));
4e3db6
-	}
4e3db6
-	bytecountm = (tmsize_t)bytecount;
4e3db6
-	if ((uint64)bytecountm!=bytecount) {
4e3db6
-		TIFFErrorExt(tif->tif_clientdata, module, "Integer overflow");
4e3db6
+        bytecountm = _TIFFCastUInt64ToSSize(tif, bytecount, module);
4e3db6
+	if (bytecountm == 0) {
4e3db6
 		return ((tmsize_t)(-1));
4e3db6
 	}
4e3db6
 	if (size != (tmsize_t)(-1) && size < bytecountm)
4e3db6
@@ -775,7 +759,7 @@ TIFFFillStrip(TIFF* tif, uint32 strip)
4e3db6
 	if ((tif->tif_flags&TIFF_NOREADRAW)==0)
4e3db6
 	{
4e3db6
 		uint64 bytecount = td->td_stripbytecount[strip];
4e3db6
-		if ((int64)bytecount <= 0) {
4e3db6
+		if( bytecount == 0 || bytecount > (uint64)TIFF_INT64_MAX ) {
4e3db6
 #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
4e3db6
 			TIFFErrorExt(tif->tif_clientdata, module,
4e3db6
 				"Invalid strip byte count %I64u, strip %lu",
4e3db6
@@ -802,7 +786,7 @@ TIFFFillStrip(TIFF* tif, uint32 strip)
4e3db6
 			    (bytecount - 4096) / 10 > (uint64)stripsize  )
4e3db6
 			{
4e3db6
 				uint64 newbytecount = (uint64)stripsize * 10 + 4096;
4e3db6
-				if( (int64)newbytecount >= 0 )
4e3db6
+				if( newbytecount == 0 || newbytecount > (uint64)TIFF_INT64_MAX )
4e3db6
 				{
4e3db6
 #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
4e3db6
 					TIFFWarningExt(tif->tif_clientdata, module,
4e3db6
@@ -1197,10 +1181,8 @@ TIFFReadRawTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size)
4e3db6
 	bytecount64 = td->td_stripbytecount[tile];
4e3db6
 	if (size != (tmsize_t)(-1) && (uint64)size < bytecount64)
4e3db6
 		bytecount64 = (uint64)size;
4e3db6
-	bytecountm = (tmsize_t)bytecount64;
4e3db6
-	if ((uint64)bytecountm!=bytecount64)
4e3db6
-	{
4e3db6
-		TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
4e3db6
+	bytecountm = _TIFFCastUInt64ToSSize(tif, bytecount64, module);
4e3db6
+        if( bytecountm == 0 ) {
4e3db6
 		return ((tmsize_t)(-1));
4e3db6
 	}
4e3db6
 	return (TIFFReadRawTile1(tif, tile, buf, bytecountm, module));
4e3db6
@@ -1222,7 +1204,7 @@ TIFFFillTile(TIFF* tif, uint32 tile)
4e3db6
 	if ((tif->tif_flags&TIFF_NOREADRAW)==0)
4e3db6
 	{
4e3db6
 		uint64 bytecount = td->td_stripbytecount[tile];
4e3db6
-		if ((int64)bytecount <= 0) {
4e3db6
+		if( bytecount == 0 || bytecount > (uint64)TIFF_INT64_MAX ) {
4e3db6
 #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
4e3db6
 			TIFFErrorExt(tif->tif_clientdata, module,
4e3db6
 				"%I64u: Invalid tile byte count, tile %lu",
4e3db6
@@ -1249,7 +1231,7 @@ TIFFFillTile(TIFF* tif, uint32 tile)
4e3db6
 			    (bytecount - 4096) / 10 > (uint64)stripsize  )
4e3db6
 			{
4e3db6
 				uint64 newbytecount = (uint64)stripsize * 10 + 4096;
4e3db6
-				if( (int64)newbytecount >= 0 )
4e3db6
+				if( newbytecount == 0 || newbytecount > (uint64)TIFF_INT64_MAX )
4e3db6
 				{
4e3db6
 #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
4e3db6
 					TIFFWarningExt(tif->tif_clientdata, module,
4e3db6
diff --git a/libtiff/tif_strip.c b/libtiff/tif_strip.c
4e3db6
index 6e9f2ef..321ad6b 100644
4e3db6
--- a/libtiff/tif_strip.c
4e3db6
+++ b/libtiff/tif_strip.c
4e3db6
@@ -131,15 +131,8 @@ TIFFVStripSize(TIFF* tif, uint32 nrows)
4e3db6
 {
4e3db6
 	static const char module[] = "TIFFVStripSize";
4e3db6
 	uint64 m;
4e3db6
-	tmsize_t n;
4e3db6
 	m=TIFFVStripSize64(tif,nrows);
4e3db6
-	n=(tmsize_t)m;
4e3db6
-	if ((uint64)n!=m)
4e3db6
-	{
4e3db6
-		TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
4e3db6
-		n=0;
4e3db6
-	}
4e3db6
-	return(n);
4e3db6
+        return _TIFFCastUInt64ToSSize(tif, m, module);
4e3db6
 }
4e3db6
 
4e3db6
 /*
4e3db6
@@ -213,15 +206,8 @@ TIFFStripSize(TIFF* tif)
4e3db6
 {
4e3db6
 	static const char module[] = "TIFFStripSize";
4e3db6
 	uint64 m;
4e3db6
-	tmsize_t n;
4e3db6
 	m=TIFFStripSize64(tif);
4e3db6
-	n=(tmsize_t)m;
4e3db6
-	if ((uint64)n!=m)
4e3db6
-	{
4e3db6
-		TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
4e3db6
-		n=0;
4e3db6
-	}
4e3db6
-	return(n);
4e3db6
+	return _TIFFCastUInt64ToSSize(tif, m, module);
4e3db6
 }
4e3db6
 
4e3db6
 /*
4e3db6
@@ -332,14 +318,8 @@ TIFFScanlineSize(TIFF* tif)
4e3db6
 {
4e3db6
 	static const char module[] = "TIFFScanlineSize";
4e3db6
 	uint64 m;
4e3db6
-	tmsize_t n;
4e3db6
 	m=TIFFScanlineSize64(tif);
4e3db6
-	n=(tmsize_t)m;
4e3db6
-	if ((uint64)n!=m) {
4e3db6
-		TIFFErrorExt(tif->tif_clientdata,module,"Integer arithmetic overflow");
4e3db6
-		n=0;
4e3db6
-	}
4e3db6
-	return(n);
4e3db6
+	return _TIFFCastUInt64ToSSize(tif, m, module);
4e3db6
 }
4e3db6
 
4e3db6
 /*
4e3db6
@@ -368,15 +348,8 @@ TIFFRasterScanlineSize(TIFF* tif)
4e3db6
 {
4e3db6
 	static const char module[] = "TIFFRasterScanlineSize";
4e3db6
 	uint64 m;
4e3db6
-	tmsize_t n;
4e3db6
 	m=TIFFRasterScanlineSize64(tif);
4e3db6
-	n=(tmsize_t)m;
4e3db6
-	if ((uint64)n!=m)
4e3db6
-	{
4e3db6
-		TIFFErrorExt(tif->tif_clientdata,module,"Integer arithmetic overflow");
4e3db6
-		n=0;
4e3db6
-	}
4e3db6
-	return(n);
4e3db6
+	return _TIFFCastUInt64ToSSize(tif, m, module);
4e3db6
 }
4e3db6
 
4e3db6
 /* vim: set ts=8 sts=8 sw=8 noet: */
4e3db6
diff --git a/libtiff/tif_tile.c b/libtiff/tif_tile.c
4e3db6
index 388e168..7d05750 100644
4e3db6
--- a/libtiff/tif_tile.c
4e3db6
+++ b/libtiff/tif_tile.c
4e3db6
@@ -183,15 +183,8 @@ TIFFTileRowSize(TIFF* tif)
4e3db6
 {
4e3db6
 	static const char module[] = "TIFFTileRowSize";
4e3db6
 	uint64 m;
4e3db6
-	tmsize_t n;
4e3db6
 	m=TIFFTileRowSize64(tif);
4e3db6
-	n=(tmsize_t)m;
4e3db6
-	if ((uint64)n!=m)
4e3db6
-	{
4e3db6
-		TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
4e3db6
-		n=0;
4e3db6
-	}
4e3db6
-	return(n);
4e3db6
+	return _TIFFCastUInt64ToSSize(tif, m, module);
4e3db6
 }
4e3db6
 
4e3db6
 /*
4e3db6
@@ -250,15 +243,8 @@ TIFFVTileSize(TIFF* tif, uint32 nrows)
4e3db6
 {
4e3db6
 	static const char module[] = "TIFFVTileSize";
4e3db6
 	uint64 m;
4e3db6
-	tmsize_t n;
4e3db6
 	m=TIFFVTileSize64(tif,nrows);
4e3db6
-	n=(tmsize_t)m;
4e3db6
-	if ((uint64)n!=m)
4e3db6
-	{
4e3db6
-		TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
4e3db6
-		n=0;
4e3db6
-	}
4e3db6
-	return(n);
4e3db6
+	return _TIFFCastUInt64ToSSize(tif, m, module);
4e3db6
 }
4e3db6
 
4e3db6
 /*
4e3db6
@@ -274,15 +260,8 @@ TIFFTileSize(TIFF* tif)
4e3db6
 {
4e3db6
 	static const char module[] = "TIFFTileSize";
4e3db6
 	uint64 m;
4e3db6
-	tmsize_t n;
4e3db6
 	m=TIFFTileSize64(tif);
4e3db6
-	n=(tmsize_t)m;
4e3db6
-	if ((uint64)n!=m)
4e3db6
-	{
4e3db6
-		TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
4e3db6
-		n=0;
4e3db6
-	}
4e3db6
-	return(n);
4e3db6
+	return _TIFFCastUInt64ToSSize(tif, m, module);
4e3db6
 }
4e3db6
 
4e3db6
 /*
4e3db6
diff --git a/libtiff/tiffiop.h b/libtiff/tiffiop.h
4e3db6
index 08e5dc4..d4b8631 100644
4e3db6
--- a/libtiff/tiffiop.h
4e3db6
+++ b/libtiff/tiffiop.h
4e3db6
@@ -79,6 +79,9 @@ extern int snprintf(char* str, size_t size, const char* format, ...);
4e3db6
 #define	FALSE	0
4e3db6
 #endif
4e3db6
 
4e3db6
+#define TIFF_SIZE_T_MAX ((size_t) ~ ((size_t)0))
4e3db6
+#define TIFF_TMSIZE_T_MAX (tmsize_t)(TIFF_SIZE_T_MAX >> 1)
4e3db6
+
4e3db6
 typedef struct client_info {
4e3db6
     struct client_info *next;
4e3db6
     void *data;
4e3db6
@@ -260,7 +263,7 @@ struct tiff {
4e3db6
 #define TIFFhowmany8_64(x) (((x)&0x07)?((uint64)(x)>>3)+1:(uint64)(x)>>3)
4e3db6
 #define TIFFroundup_64(x, y) (TIFFhowmany_64(x,y)*(y))
4e3db6
 
4e3db6
-/* Safe multiply which returns zero if there is an integer overflow */
4e3db6
+/* Safe multiply which returns zero if there is an *unsigned* integer overflow. This macro is not safe for *signed* integer types */
4e3db6
 #define TIFFSafeMultiply(t,v,m) ((((t)(m) != (t)0) && (((t)(((v)*(m))/(m))) == (t)(v))) ? (t)((v)*(m)) : (t)0)
4e3db6
 
4e3db6
 #define TIFFmax(A,B) ((A)>(B)?(A):(B))
4e3db6
@@ -366,6 +369,8 @@ extern TIFFErrorHandlerExt _TIFFerrorHandlerExt;
4e3db6
 
4e3db6
 extern uint32 _TIFFMultiply32(TIFF*, uint32, uint32, const char*);
4e3db6
 extern uint64 _TIFFMultiply64(TIFF*, uint64, uint64, const char*);
4e3db6
+extern tmsize_t _TIFFMultiplySSize(TIFF*, tmsize_t, tmsize_t, const char*);
4e3db6
+extern tmsize_t _TIFFCastUInt64ToSSize(TIFF*, uint64, const char*);
4e3db6
 extern void* _TIFFCheckMalloc(TIFF*, tmsize_t, tmsize_t, const char*);
4e3db6
 extern void* _TIFFCheckRealloc(TIFF*, void*, tmsize_t, tmsize_t, const char*);
4e3db6
 
4e3db6
-- 
4e3db6
2.21.0
4e3db6