Return-Path: <tiff-bounces@lists.maptools.org>
X-Original-To: info@awaresystems.be
Delivered-To: info@awaresystems.be
Received: from mx-j.b-one.net (mx-j.one.com [91.198.169.57])
	by mail9.b-one.net (Postfix) with ESMTP id A5ED7400161
	for <info@awaresystems.be>; Mon, 18 Apr 2011 19:58:14 +0200 (CEST)
Received: by mx-j.b-one.net (Postfix, from userid 106)
	id 9CAA56F79175; Mon, 18 Apr 2011 19:58:14 +0200 (CEST)
X-Virus-Scanned: by one.com
X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4
Received: from lists.maptools.org (lists.maptools.org [65.39.174.144]) by
 mx-j.b-one.net (Postfix) with ESMTP id E69E56F79175 for
 <info@awaresystems.be>; Mon, 18 Apr 2011 19:58:11 +0200 (CEST)
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by
 lists.maptools.org (Postfix) with ESMTP id B654886B22; Mon, 18 Apr 2011
 12:55:56 -0500 (EST)
Received: from mail-vw0-f44.google.com (mail-vw0-f44.google.com
 [209.85.212.44]) by lists.maptools.org (Postfix) with ESMTPS id F04A286B8D
 for <tiff@lists.maptools.org>; Mon, 18 Apr 2011 12:42:46 -0500 (EST)
Received: by vws12 with SMTP id 12so3747558vws.3 for
 <tiff@lists.maptools.org>; Mon, 18 Apr 2011 10:42:45 -0700 (PDT)
Received: by 10.220.118.17 with SMTP id t17mr1585704vcq.0.1303148565193; Mon,
 18 Apr 2011 10:42:45 -0700 (PDT)
Received: from [172.31.56.35] ([144.212.3.4]) by mx.google.com with ESMTPS id
 m4sm1149362vcr.19.2011.04.18.10.42.44 (version=TLSv1/SSLv3 cipher=OTHER);
 Mon, 18 Apr 2011 10:42:44 -0700 (PDT)
Message-ID: <4DAC780F.1000803@gmail.com>
Date: Mon, 18 Apr 2011 13:42:39 -0400
From: Ashish Uthama <newsgroups.ashish.uthama@gmail.com>
User-Agent: Mozilla-Thunderbird 2.0.0.24 (X11/20100329)
MIME-Version: 1.0
To: tiff@lists.maptools.org
Subject: [Tiff] WhiteLevel with 3.9.5
X-BeenThere: tiff@lists.maptools.org
X-Mailman-Version: 2.1.9
Precedence: list
Reply-To: newsgroups.first.uthama@gmail.com
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

Hi folks,

I am trying to use the 3.9.5 library to handle a DNG file with a subIFD.
The subIFD has a WhiteLevel tag 
http://www.awaresystems.be/imaging/tiff/tifftags/whitelevel.html which 
appears to cause a segfault with 3.9.5 (Used to work fine with 3.7.1).


Debugging 3.9.5, I noticed that TIFFSetField at 1739 was called for this 
tag:

tif_dirread.c:

   1737                           ok = (fip->field_passcount ?
   1738                               TIFFSetField(tif, dp->tdir_tag, 1, 
&v32)
   1739                             : TIFFSetField(tif, dp->tdir_tag, v32));

which cases the memcpy in 506 to fail:

tif_dir.c:
    497                 if ((fip->field_passcount
    498                     || fip->field_writecount == TIFF_VARIABLE
    499                     || fip->field_writecount == TIFF_VARIABLE2
    500                     || fip->field_writecount == TIFF_SPP
    501                     || tv->count > 1)
    502                     && fip->field_tag != TIFFTAG_PAGENUMBER
    503                     && fip->field_tag != TIFFTAG_HALFTONEHINTS
    504                     && fip->field_tag != TIFFTAG_YCBCRSUBSAMPLING
    505                     && fip->field_tag != TIFFTAG_DOTRANGE) {
    506                     _TIFFmemcpy(tv->value, va_arg(ap, void *),
    507                                 tv->count * tv_size);
    508                 } else {
    509                     /*
    510                      * XXX: The following loop required to handle
    511                      * TIFFTAG_PAGENUMBER, TIFFTAG_HALFTONEHINTS,
    512                      * TIFFTAG_YCBCRSUBSAMPLING and 
TIFFTAG_DOTRANGE tags.
    513                      * These tags are actually arrays and should 
be passed as
    514                      * array pointers to TIFFSetField() 
function, but actually
    515                      * passed as a list of separate values. This 
behaviour
    516                      * must be changed in the future!
    517                      */

Based on the comment (510-517), and the description for the tag, I added 
TIFFTAG_WHITELEVEL after line 505 to skip the memcpy and use the else 
block to process it.

Would this be the right way to handle this tag?


Ashish



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