48 lines
1.3 KiB
Diff
48 lines
1.3 KiB
Diff
From 98e37a5c822bdfed2343e6ab9d03680e85783aef Mon Sep 17 00:00:00 2001
|
|
From: Thomas Bernard <miniupnp@free.fr>
|
|
Date: Mon, 11 Feb 2019 10:05:33 +0100
|
|
Subject: [PATCH] (CVE-2018-12900) check that (Tile Width)*(Samples/Pixel) do
|
|
no overflow
|
|
|
|
fixes bug 2833
|
|
|
|
(cherry picked from commit 2b0d0e699730d1f26bbeba8397bfdf0e9e01e59d)
|
|
---
|
|
tools/tiffcp.c | 9 ++++++++-
|
|
1 file changed, 8 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/tools/tiffcp.c b/tools/tiffcp.c
|
|
index 489459a7..96f14728 100644
|
|
--- a/tools/tiffcp.c
|
|
+++ b/tools/tiffcp.c
|
|
@@ -43,6 +43,7 @@
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
+#include <limits.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
@@ -1391,7 +1392,7 @@ DECLAREreadFunc(readSeparateTilesIntoBuffer)
|
|
int status = 1;
|
|
uint32 imagew = TIFFRasterScanlineSize(in);
|
|
uint32 tilew = TIFFTileRowSize(in);
|
|
- int iskew = imagew - tilew*spp;
|
|
+ int iskew;
|
|
tsize_t tilesize = TIFFTileSize(in);
|
|
tdata_t tilebuf;
|
|
uint8* bufp = (uint8*) buf;
|
|
@@ -1399,6 +1400,12 @@ DECLAREreadFunc(readSeparateTilesIntoBuffer)
|
|
uint32 row;
|
|
uint16 bps = 0, bytes_per_sample;
|
|
|
|
+ if (tilew && spp > (INT_MAX / tilew))
|
|
+ {
|
|
+ TIFFError(TIFFFileName(in), "Error, cannot handle that much samples per tile row (Tile Width * Samples/Pixel)");
|
|
+ return 0;
|
|
+ }
|
|
+ iskew = imagew - tilew*spp;
|
|
tilebuf = _TIFFmalloc(tilesize);
|
|
if (tilebuf == 0)
|
|
return 0;
|