Return-Path: <awaresystems.be+caf_=filtered=awaresystems.be@gmail.com>
Delivered-To: <filtered@awaresystems.be>
Received: from mx10.public.one.com ([10.246.18.30])
	by mail6.local.one.com (Dovecot) with LMTP id USY+LNku4FeXSQAAsyOMew
	for <filtered@awaresystems.be>; Mon, 19 Sep 2016 18:50:04 +0000
X-HalOne-ID: dfd521fb-7e99-11e6-b362-246e9615723c
Received: from mail-qk0-f182.google.com (unknown [209.85.220.182])
	by mx10.public.one.com (Halon Mail Gateway) with ESMTPS
	for <filtered@awaresystems.be>; Mon, 19 Sep 2016 18:50:02 +0000 (UTC)
Received: by mail-qk0-f182.google.com with SMTP id z190so155994066qkc.3
        for <filtered@awaresystems.be>; Mon, 19 Sep 2016 11:50:02 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-original-authentication-results:x-gm-message-state:delivered-to
         :from:to:date:message-id:references:mime-version:cc:subject
         :precedence:list-id:list-unsubscribe:list-archive:list-post
         :list-help:list-subscribe:content-transfer-encoding:sender:errors-to;
        bh=9bf/cFxvCJKINYYY8ZaZBxEwY5qFDKOB5X0oLLoJUNM=;
        b=DRWlE9lQ/t9p9Hw/bxo9JIMIv1dzp1+fTNXDqtyUuLNOzaeRhW5JetALvn6CVkqomK
         wkYMhO3/mGwS/Jdz047z7i6Z9kp3xECoYyU8FnYR0MeI00m5y4rLL853SNV2FU5c3rnG
         t2XOey8qbGfcRmOklR7a3QwQKnrCPdTs0byxzlSZf8qA2A0aTLM1gDr9I5eCOuH699Rt
         gYYs58vrT3TlLk2y/JeRquKanFX5RXjWAxax3OH9nVWUqdfWdTuWifi7vJjeTO7P7Gns
         tJDZ2xFP3T/IwWZtb8Zy8GVVvi4BpMMkZ/I2IANxbZeB20Iz89FU48BjS7pfHpv3IV5j
         Bycw==
X-Original-Authentication-Results: mx.google.com;       spf=neutral (google.com: 94.23.4.142 is neither permitted nor denied by best guess record for domain of tiff-bounces@lists.maptools.org) smtp.mailfrom=tiff-bounces@lists.maptools.org;       dmarc=fail (p=NONE dis=NONE) header.from=seznam.cz
X-Gm-Message-State: AE9vXwOS2JkC9ya423mW8YX3bruFP2GJdibifnc3WxVU8oW/J2+xepXYYVx6zhpdw216YV7ZwGMLcBGd7qXyVnoHCTfrS4A=
X-Received: by 10.55.23.193 with SMTP id 62mr31340427qkx.218.1474311001541;
        Mon, 19 Sep 2016 11:50:01 -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.55.161.4 with SMTP id k4csp1127693qke;
        Mon, 19 Sep 2016 11:50:00 -0700 (PDT)
X-Received: by 10.28.238.144 with SMTP id j16mr11643365wmi.10.1474311000220;
        Mon, 19 Sep 2016 11:50:00 -0700 (PDT)
Return-Path: <tiff-bounces@lists.maptools.org>
Received: from lists.maptools.org (ks365428.kimsufi.com. [94.23.4.142])
        by mx.google.com with ESMTP id jv8si20892845wjc.144.2016.09.19.11.49.44;
        Mon, 19 Sep 2016 11:50:00 -0700 (PDT)
Received-SPF: neutral (google.com: 94.23.4.142 is neither permitted nor denied by best guess record for domain of tiff-bounces@lists.maptools.org) client-ip=94.23.4.142;
Authentication-Results: mx.google.com;
       spf=neutral (google.com: 94.23.4.142 is neither permitted nor denied by best guess record for domain of tiff-bounces@lists.maptools.org) smtp.mailfrom=tiff-bounces@lists.maptools.org;
       dmarc=fail (p=NONE dis=NONE) header.from=seznam.cz
Received: from [10.1.0.241] (localhost.localdomain [127.0.0.1])
	by lists.maptools.org (Postfix) with ESMTP id 9ADA435C037;
	Mon, 19 Sep 2016 13:48:52 -0500 (EST)
Received: from mxh2.seznam.cz (mxh2.seznam.cz [77.75.76.26])
	by lists.maptools.org (Postfix) with ESMTPS id CC3A535C02B
	for <Tiff@lists.maptools.org>; Mon, 19 Sep 2016 13:47:38 -0500 (EST)
Received: from email.seznam.cz
	by email-smtpc5b.ng.seznam.cz (email-smtpc5b.ng.seznam.cz
	[10.23.13.135]) id 1aa0f5dc3ca352141ab10332;
	Mon, 19 Sep 2016 20:47:29 +0200 (CEST)
Received: from unknown ([::ffff:83.208.231.197])
	by email.seznam.cz (szn-ebox-4.5.168) with HTTP;
	Mon, 19 Sep 2016 20:47:26 +0200 (CEST)
From: <mickey.rose@seznam.cz>
To: <rleigh@codelibre.net>
Date: Mon, 19 Sep 2016 20:47:26 +0200 (CEST)
Message-Id: <4UG.4SjY.4HYQUi457Od.1Nu3A{@seznam.cz>
References: <d9b8967a91d9195f124fbf452ae661ad@codelibre.net>
Mime-Version: 1.0 (szn-mime-2.0.12)
X-Mailer: szn-ebox-4.5.168
Cc: Tiff@lists.maptools.org
Subject: Re: [Tiff] Accuracy of TIFF Field metadata (COLORMAP)
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

> I recently discovered a problem on Windows where I was getting a strange
> runtime error ("Run-Time Check Failure #2 -S") which turns out was due
> to stack corruption. This was due to calling TIFFGetField with the
> wrong parameters, and that was because the field metadata in
> tif_dirinfo.c was wrong. Here's the broken bit:
>
> { TIFFTAG_COLORMAP, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_OTHER,
> TIFF_SETGET_UNDEFINED, FIELD_COLORMAP, 1, 0, "ColorMap", NULL },

These values are correct. There's field_passcount=0, which means you
shouldn't be asking for the nunber of colors (&n in your code) from
TIFFGetField. See:

https://github.com/vadz/libtiff/blob/c87dc82d7ff8214bd417176bd76f3fe94a237659/libtiff/tif_dir.c#L327
https://github.com/vadz/libtiff/blob/c87dc82d7ff8214bd417176bd76f3fe94a237659/libtiff/tif_dir.c#L939

TIFFGetField gives you the three uint16* pointers to r/g/b arrays,
whose length, i.e. the number of colors in the palette, is determined
by bitspersample (n = 1<<bitspersample)

> Assuming I'm not totally wrong in my understanding, the wider question
> here is this: is the field metadata generally usable? Or does it need a
> proper audit of every field to ensure the types are correct in every
> case? Would it help to use the VARIABLE/VARIABLE2/SPP values in place
> of negative values?

There's a comment at the top acknowledging that symbolic names should
be used, and something about formatting... I assume they'd make the
table a bit harder to skim through.

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