Return-Path: <tiff-bounces@remotesensing.org>
Received: from inmx017.isp.belgacom.be (inmx017.isp.belgacom.be [195.238.2.129])
        by mailst035.isp.belgacom.be (8.12.11/8.12.11/Skynet-MAILSTORE-2.14) with ESMTP id j2F0cUOZ024880
        for <joris.at.lebbeke@skynet.be>; Tue, 15 Mar 2005 01:38:30 +0100
        (envelope-from <tiff-bounces@remotesensing.org>)
Received: from xserve.flids.com (adsl-065-083-169-202.sip.mco.bellsouth.net [65.83.169.202])
        by inmx017.isp.belgacom.be (8.12.11/8.12.11/Skynet-IN-2.32) with ESMTP id j2F0cJja020108
        for <joris.at.lebbeke@skynet.be>; Tue, 15 Mar 2005 01:38:20 +0100
        (envelope-from <tiff-bounces@remotesensing.org>)
Received: from adsl-065-083-169-202.sip.mco.bellsouth.net (localhost [127.0.0.1])
	by xserve.flids.com (Postfix) with ESMTP
	id 5DB1613A13AF; Mon, 14 Mar 2005 19:38:06 -0500 (EST)
X-Original-To: tiff@remotesensing.org
Delivered-To: tiff@remotesensing.org
Received: from outmx013.isp.belgacom.be (outmx013.isp.belgacom.be
	[195.238.3.64])
	by xserve.flids.com (Postfix) with ESMTP id 209B513A138C
	for <tiff@remotesensing.org>; Mon, 14 Mar 2005 19:38:04 -0500 (EST)
Received: from outmx013.isp.belgacom.be (localhost [127.0.0.1])
	by outmx013.isp.belgacom.be (8.12.11/8.12.11/Skynet-OUT-2.22) with
	ESMTP id j2F0c23a000913
	for <tiff@remotesensing.org>; Tue, 15 Mar 2005 01:38:02 +0100
	(envelope-from <joris.at.lebbeke@skynet.be>)
Received: from dfgrrxsknr4e (11-167.245.81.adsl.skynet.be [81.245.167.11])
	by outmx013.isp.belgacom.be (8.12.11/8.12.11/Skynet-OUT-2.22) with SMTP
	id j2F0bueg000871; Tue, 15 Mar 2005 01:37:56 +0100
	(envelope-from <joris.at.lebbeke@skynet.be>)
Message-ID: <000d01c528f7$5d338da0$0ba7f551@dfgrrxsknr4e>
From: "Joris" <joris.at.lebbeke@skynet.be>
To: <warmerdam@pobox.com>, "Kalman Miklos" <sintax@zenonbio.hu>
References: <4227471D.6020509@zenonbio.hu>
	<931f8ea9050303094829fd9755@mail.gmail.com>
Subject: Re: [Tiff] LibTIFF question
Date: Tue, 15 Mar 2005 01:38:39 +0100
MIME-Version: 1.0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2800.1478
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1478
Cc: tiff@remotesensing.org
X-BeenThere: tiff@remotesensing.org
X-Mailman-Version: 2.1.2
Precedence: list
List-Id: TIFF and libtiff discussion  <tiff.remotesensing.org>
List-Unsubscribe: <http://xserve.flids.com/mailman/listinfo/tiff>,
	<mailto:tiff-request@remotesensing.org?subject=unsubscribe>
List-Archive: <http://xserve.flids.com/pipermail/tiff>
List-Post: <mailto:tiff@remotesensing.org>
List-Help: <mailto:tiff-request@remotesensing.org?subject=help>
List-Subscribe: <http://xserve.flids.com/mailman/listinfo/tiff>,
	<mailto:tiff-request@remotesensing.org?subject=subscribe>
Sender: tiff-bounces@remotesensing.org
Errors-To: tiff-bounces@remotesensing.org
X-UIDL: bfa5456b4da183dcebf18f1817ad724a

Frank,

Frank wrote:
> I think you should be doing something like:
>
>   uint16 count;
>   int *data = NULL;
>
>   TIFFGetField( m_TIFF, 50653, &count, &data );

That is almost a perfect solution, thanks to the so-called auto-registration.
However, one thing seems missing, being the datatype. Suppose this method is
used to retrieve, for example, the ModelPixelScaleTag tag value. If the calling
code simply assumes the datatype of the returned value is DOUBLE, and only
double-checks the count, it's bound to overrun the buffer pointed to by 'data'
and crash badly if it ever encounters a TIFF file where this same tag id stores
3 byte values.

Due to the number of private tags, and due to the fact that at one time
registration was hard, I expect some tag uses are unregistered and situations
like these are likely. Besides, we need to protect ourselves from this mishap
even if it should not be likely.

So my question is, is there a way to retrieve the datatype of these
auto-registered tags? Am I right in thinking that TIFFFindFieldInfo with
TIFF_ANY for the third parameter returns the 'registration' structure as build
by this auto-registration scheme? Is checking the FieldType member of this
structure good and sufficient to protect the calling code from the above
mentioned mishap?



Joris Van Damme
info@awaresystems.be
http://www.awaresystems.be/
Download your free TIFF tag viewer for windows here:
http://www.awaresystems.be/imaging/tiff/astifftagviewer.html

_______________________________________________
Tiff mailing list
Tiff@remotesensing.org
http://xserve.flids.com/mailman/listinfo/tiff
