Return-Path: <awaresystems.be+caf_=filtered=awaresystems.be@gmail.com>
Delivered-To: filtered@awaresystems.be
Received: from mx-r.one.com (mx-r.one.com [91.198.169.249])
	by mail9.b-one.net (Postfix) with ESMTP id 906B9C2D1C6
	for <filtered@awaresystems.be>; Fri, 18 May 2012 16:26:58 +0200 (CEST)
X-Virus-Scanned: by one.com
Received-SPF: pass (mx-r: domain of awaresystems.be+caf_=filtered=awaresystems.be@gmail.com designates 74.125.82.52 as permitted sender)
X-Greylist: whitelisted by SQLgrey-1.8.0-rc2
Received: from mail-wg0-f52.google.com (mail-wg0-f52.google.com [74.125.82.52])
	by mx-r.one.com (Postfix) with ESMTP id 5A46E3E3F61
	for <filtered@awaresystems.be>; Fri, 18 May 2012 14:26:58 +0000 (UTC)
Received: by wgbgn7 with SMTP id gn7so2313724wgb.33
        for <filtered@awaresystems.be>; Fri, 18 May 2012 07:26:58 -0700 (PDT)
Received: by 10.180.102.3 with SMTP id fk3mr2105870wib.9.1337350805514;
        Fri, 18 May 2012 07:20:05 -0700 (PDT)
X-Forwarded-To: filtered@awaresystems.be
X-Forwarded-For: awaresystems.be@gmail.com filtered@awaresystems.be
Delivered-To: awaresystems.be@gmail.com
Received: by 10.180.19.165 with SMTP id g5csp93040wie;
        Fri, 18 May 2012 07:20:04 -0700 (PDT)
Received: by 10.216.150.225 with SMTP id z75mr7531761wej.77.1337350803209;
        Fri, 18 May 2012 07:20:03 -0700 (PDT)
Received-SPF: softfail (google.com: best guess record for domain of transitioning tiff-bounces@lists.maptools.org does not designate 91.198.169.249 as permitted sender) client-ip=91.198.169.249;
Received: by 10.124.201.135 with POP3 id fa7mf2101792wgb.4;
        Fri, 18 May 2012 07:20:03 -0700 (PDT)
X-Gmail-Fetch-Info: info@awaresystems.be 1 pop.awaresystems.be 110 info@awaresystems.be
Delivered-To: info@awaresystems.be
Received: from mx-r.one.com (mx-r.one.com [91.198.169.249])
	by mail9.b-one.net (Postfix) with ESMTP id 9C918C2D1C6
	for <info@awaresystems.be>; Fri, 18 May 2012 15:26:25 +0200 (CEST)
X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0-rc2
Received: from lists.maptools.org (lists.maptools.org [65.39.174.144])
	by mx-r.one.com (Postfix) with ESMTP id 44A4236EAEC
	for <info@awaresystems.be>; Fri, 18 May 2012 13:26:25 +0000 (UTC)
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by lists.maptools.org (Postfix) with ESMTP id 0017D1EDAD3;
	Fri, 18 May 2012 08:24:55 -0500 (EST)
Received: from mail-bk0-f44.google.com (mail-bk0-f44.google.com
	[209.85.214.44])
	by lists.maptools.org (Postfix) with ESMTPS id 0AC3C1EDAD3
	for <tiff@lists.maptools.org>; Fri, 18 May 2012 08:24:02 -0500 (EST)
Received: by bkty8 with SMTP id y8so2302657bkt.3
	for <tiff@lists.maptools.org>; Fri, 18 May 2012 06:24:01 -0700 (PDT)
Received: by 10.204.132.87 with SMTP id a23mr3548107bkt.134.1337347441614;
	Fri, 18 May 2012 06:24:01 -0700 (PDT)
Received: from [192.168.1.100] (77-58-250-68.dclient.hispeed.ch.
	[77.58.250.68])
	by mx.google.com with ESMTPS id z14sm17440290bky.15.2012.05.18.06.23.59
	(version=SSLv3 cipher=OTHER); Fri, 18 May 2012 06:24:00 -0700 (PDT)
Message-ID: <4FB64D6F.5060401@gmail.com>
Date: Fri, 18 May 2012 15:23:59 +0200
From: Sandro Mani <manisandro@gmail.com>
User-Agent: Mozilla/5.0 (X11; Linux x86_64;
	rv:12.0) Gecko/20120507 Thunderbird/12.0.1
MIME-Version: 1.0
To: tiff@lists.maptools.org
Subject: [Tiff] TIFFGetField: count should be uint32_t (Bug in documentation)
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>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Sender: tiff-bounces@lists.maptools.org
Errors-To: tiff-bounces@lists.maptools.org

Hello,
according to [1], when querying multi-valued fields with TiffGetField, 
count should be of a 16-bit unsigned integer. However, in various places 
in the source libtiff source code, a 32-bit unsigned integer is used. 
Indeed, a nasty bug I encountered was caused by count being 16 bits wide:

  uint16_t count;
  uint32_t width;
  void* data;
  std::cout<<&width<<" "<<&count<<std::endl;

  TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width);
  std::cout<<width<<std::endl;

  TIFFGetField(tif, TIFFTAG_MODELTIEPOINT, &count, &data);
  std::cout<<width<<std::endl;

Output:
0x7fffa4d38a68 0x7fffa4d38a66
7721
0
=> Count overflowed into width

If my analysis is correct, I guess the documentation should be fixed.

Thanks,
Sandro

[1] http://www.remotesensing.org/libtiff/man/TIFFGetField.3tiff.html

_______________________________________________
Tiff mailing list: Tiff@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
