|
commit b34209fede77aa203cd5adcd9638ccc70731a50f
|
|
Author: erouault <erouault>
|
|
Date: Sat Dec 3 16:40:01 2016 +0000
|
|
|
|
* tools/tiffcp.c: fix uint32 underflow/overflow that can cause heap-based
|
|
buffer overflow.
|
|
Reported by Agostino Sarubbo.
|
|
Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2610
|
|
|
|
diff --git a/ChangeLog b/ChangeLog
|
|
index 94be038..8ee76c0 100644
|
|
--- a/ChangeLog
|
|
+++ b/ChangeLog
|
|
@@ -1,5 +1,12 @@
|
|
2016-12-03 Even Rouault <even.rouault at spatialys.com>
|
|
|
|
+ * tools/tiffcp.c: fix uint32 underflow/overflow that can cause heap-based
|
|
+ buffer overflow.
|
|
+ Reported by Agostino Sarubbo.
|
|
+ Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2610
|
|
+
|
|
+2016-12-03 Even Rouault <even.rouault at spatialys.com>
|
|
+
|
|
* tools/tiffcp.c: avoid potential division by zero if BitsPerSamples tag is
|
|
missing.
|
|
Reported by Agostino Sarubbo.
|
|
diff --git a/tools/tiffcp.c b/tools/tiffcp.c
|
|
index 142cbb0..6d96bb8 100644
|
|
--- a/tools/tiffcp.c
|
|
+++ b/tools/tiffcp.c
|
|
@@ -1,4 +1,4 @@
|
|
-/* $Id: tiffcp.c,v 1.58 2016-12-03 15:44:15 erouault Exp $ */
|
|
+/* $Id: tiffcp.c,v 1.59 2016-12-03 16:40:01 erouault Exp $ */
|
|
|
|
/*
|
|
* Copyright (c) 1988-1997 Sam Leffler
|
|
@@ -1163,7 +1163,7 @@ bad:
|
|
|
|
static void
|
|
cpStripToTile(uint8* out, uint8* in,
|
|
- uint32 rows, uint32 cols, int outskew, int inskew)
|
|
+ uint32 rows, uint32 cols, int outskew, int64 inskew)
|
|
{
|
|
while (rows-- > 0) {
|
|
uint32 j = cols;
|
|
@@ -1320,7 +1320,7 @@ DECLAREreadFunc(readContigTilesIntoBuffer)
|
|
tdata_t tilebuf;
|
|
uint32 imagew = TIFFScanlineSize(in);
|
|
uint32 tilew = TIFFTileRowSize(in);
|
|
- int iskew = imagew - tilew;
|
|
+ int64 iskew = (int64)imagew - (int64)tilew;
|
|
uint8* bufp = (uint8*) buf;
|
|
uint32 tw, tl;
|
|
uint32 row;
|
|
@@ -1348,7 +1348,7 @@ DECLAREreadFunc(readContigTilesIntoBuffer)
|
|
status = 0;
|
|
goto done;
|
|
}
|
|
- if (colb + tilew > imagew) {
|
|
+ if (colb > iskew) {
|
|
uint32 width = imagew - colb;
|
|
uint32 oskew = tilew - width;
|
|
cpStripToTile(bufp + colb,
|