X-Account-Key: account1
X-UIDL: dd2ef546af44879d076a8f37b8944142
X-Mozilla-Status: 0011
X-Mozilla-Status2: 00000000
X-Mozilla-Keys:                                                                                 
Received: from lists.maptools.org (localhost [127.0.0.1])
	by mail.howardsilvan.com (Postfix) with ESMTPS id E97C9C4211A
	for <faxguy@howardsilvan.com>; Sat, 14 Nov 2015 06:34:11 -0800 (PST)
Received: from lists.maptools.org ([94.23.4.142] helo=lists.maptools.org)
	by fangorn.howardsilvan.com with SMTP (2.3.3); 14 Nov 2015 06:34:11 -0800
Received: from [10.1.0.241] (localhost.localdomain [127.0.0.1])
	by lists.maptools.org (Postfix) with ESMTP id 4288E35C02A;
	Sat, 14 Nov 2015 09:33:55 -0500 (EST)
Received: from blade.simplesystems.org (blade.simplesystems.org [65.66.246.74])
	by lists.maptools.org (Postfix) with ESMTPS id 4393835C028
	for <tiff@lists.maptools.org>; Sat, 14 Nov 2015 09:33:44 -0500 (EST)
Received: from freddy.simplesystems.org (freddy.simplesystems.org	[65.66.246.65])
	by blade.simplesystems.org (8.14.4+Sun/8.14.4)
	with ESMTP id	tAEEXgsa010740; Sat, 14 Nov 2015 08:33:42 -0600 (CST)
Date: Sat, 14 Nov 2015 08:33:42 -0600 (CST)
From: Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
X-X-Sender: bfriesen@freddy.simplesystems.org
To: Even Rouault <even.rouault@spatialys.com>
In-Reply-To: <201511141419.20555.even.rouault@spatialys.com>
Message-ID: <alpine.GSO.2.01.1511140826440.1673@freddy.simplesystems.org>
References: <201511141419.20555.even.rouault@spatialys.com>
User-Agent: Alpine 2.01 (GSO 1266 2009-07-14)
MIME-Version: 1.0
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.2
	(blade.simplesystems.org [65.66.246.90]);	Sat, 14 Nov 2015 08:33:42 -0600
 (CST)
Cc: tiff@lists.maptools.org
Subject: Re: [Tiff] ColorMap and high bit depth
X-BeenThere: tiff@lists.maptools.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: TIFF and libtiff discussion <tiff.lists.maptools.org>
List-Unsubscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
	<mailto:tiff-request@lists.maptools.org?subject=unsubscribe>
List-Archive: <http://lists.maptools.org/mailman/private/tiff>
List-Post: <mailto:tiff@lists.maptools.org>
List-Help: <mailto:tiff-request@lists.maptools.org?subject=help>
List-Subscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
	<mailto:tiff-request@lists.maptools.org?subject=subscribe>
Sender: tiff-bounces@lists.maptools.org
Errors-To: tiff-bounces@lists.maptools.org
X-Assp-ID: fangorn.howardsilvan.com m1-11651-02694
X-Assp-Session: 7F0662A6C6D0 (mail 1)
X-Assp-Detected-RIP: 65.66.246.65, 65.66.246.74
X-Assp-Source-IP: 65.66.246.65
X-Assp-Envelope-From: tiff-bounces@lists.maptools.org
X-Assp-Intended-For: faxguy@howardsilvan.com
X-Assp-Version: 2.3.3(14029) on fangorn.howardsilvan.com
X-Assp-Server-TLS: yes
X-Assp-Delay: not delayed (whitelisted); 14 Nov 2015 06:34:11 -0800
X-Assp-Whitelisted: Yes (whitelistdb)
Return-Path: tiff-bounces@lists.maptools.org
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

On Sat, 14 Nov 2015, Even Rouault wrote:

> Hi,
>
> I've noticed that currently we support ColorMap up to BitsPerSample=28. Since
> 3 * 2^28 * sizeof(uint16) = 1.6 GB (< 2 GB, which is the sanity check in
> TIFFReadDirEntryArray() ). And this is read by default at file opening, so it
> can be used as a sort of DoS due to excessive I/O and memory usage.
>
> Does it make sense to support ColorMap with such high bit depths ? Couldn't we
> limit reading ColorTable up to 24 bit for example (which would put the limit
> to 50 MB) ? Another option would be to defer reading the color map until it is
> explicitly requested by the application, but do we need such complication ?

28 bits seems excessive to me.  GraphicsMagick (and likely 
ImageMagick) only support colormaps with a 16-bit index (it would be 
nice to support a bit more though).  Colormaps decrease in value as 
they become larger.

The colormap is not compressed so the best defense against DOS is to 
check that the file has provided the backing data for the colormap 
before making the memory allocation.  It is easy to declare a 1.6 GB 
colormap, but much more difficult to supply it.

Bob
-- 
Bob Friesenhahn
bfriesen@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/
_______________________________________________
Tiff mailing list: Tiff@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/


