From 712fe9f5b9795c5a3e80f38db90dad11e6a8bb6a Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Tue, 10 Nov 2020 01:53:56 +0100 Subject: [PATCH 1/2] fix warning messages (v32 is unsigned) --- libtiff/tif_dir.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libtiff/tif_dir.c b/libtiff/tif_dir.c index ba8ba2e7..347b7115 100644 --- a/libtiff/tif_dir.c +++ b/libtiff/tif_dir.c @@ -394,7 +394,7 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) if (tif->tif_mode != O_RDONLY) goto badvalue32; TIFFWarningExt(tif->tif_clientdata, tif->tif_name, - "Nonstandard tile width %d, convert file", v32); + "Nonstandard tile width %u, convert file", v32); } td->td_tilewidth = v32; tif->tif_flags |= TIFF_ISTILED; @@ -405,7 +405,7 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) if (tif->tif_mode != O_RDONLY) goto badvalue32; TIFFWarningExt(tif->tif_clientdata, tif->tif_name, - "Nonstandard tile length %d, convert file", v32); + "Nonstandard tile length %u, convert file", v32); } td->td_tilelength = v32; tif->tif_flags |= TIFF_ISTILED; From c8d613ef497058fe653c467fc84c70a62a4a71b2 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Tue, 10 Nov 2020 01:54:30 +0100 Subject: [PATCH 2/2] gtTileContig(): check Tile width for overflow fixes #211 --- libtiff/tif_getimage.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/libtiff/tif_getimage.c b/libtiff/tif_getimage.c index 4da785d3..96ab1460 100644 --- a/libtiff/tif_getimage.c +++ b/libtiff/tif_getimage.c @@ -29,6 +29,7 @@ */ #include "tiffiop.h" #include +#include static int gtTileContig(TIFFRGBAImage*, uint32*, uint32, uint32); static int gtTileSeparate(TIFFRGBAImage*, uint32*, uint32, uint32); @@ -645,12 +646,20 @@ gtTileContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) flip = setorientation(img); if (flip & FLIP_VERTICALLY) { - y = h - 1; - toskew = -(int32)(tw + w); + if ((tw + w) > INT_MAX) { + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", "unsupported tile size (too wide)"); + return (0); + } + y = h - 1; + toskew = -(int32)(tw + w); } else { - y = 0; - toskew = -(int32)(tw - w); + if (tw > (INT_MAX + w)) { + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", "unsupported tile size (too wide)"); + return (0); + } + y = 0; + toskew = -(int32)(tw - w); } /*