Return-Path: <awaresystems.be+caf_=filtered=awaresystems.be@gmail.com>
Delivered-To: filtered@awaresystems.be
Received: from mx7.public.one.com ([10.246.18.27])
	by mail6.local.one.com (Dovecot) with LMTP id QUpRLNhOW1m6sgEAsyOMew
	for <filtered@awaresystems.be>; Tue, 04 Jul 2017 11:07:34 +0000
X-HalOne-ID: f9c08abe-60a8-11e7-8f54-549f350a6292
Received: from mail-oi0-f45.google.com (unknown [209.85.218.45])
	by mx7.public.one.com (Halon) with ESMTPS
	id f9c08abe-60a8-11e7-8f54-549f350a6292;
	Tue, 04 Jul 2017 11:07:32 +0000 (UTC)
Received: by mail-oi0-f45.google.com with SMTP id p188so100815756oia.0
        for <filtered@awaresystems.be>; Tue, 04 Jul 2017 04:07:32 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-original-authentication-results:x-gm-message-state:delivered-to
         :message-id:date:from:user-agent:mime-version:to:references
         :in-reply-to:subject:precedence:list-id:list-unsubscribe
         :list-archive:list-post:list-help:list-subscribe:sender:errors-to;
        bh=r46d4JmKAPzJgegbTmuPT8DW/uWOr6gaBdDvIY560vU=;
        b=IxV9UgeDzD0d0/nCdesgOA9lkbUHXoJMBzTUwzFYg/yt6/ttk+0zxzmD/V8Vxu7G4n
         o3HnspzSbWuHQcslKzD/0W+19DM2Iaf9PO2RHPr4JN9pfVlSt6OphUHt1BRol0coWXJw
         45D+tLXGEmR9I80uhTXP24ravpp6Uy1GbNCXgRyB4bkwatRVPCVrUNDydBJTOt+PObzL
         knrQHplAoBk5AxhDDoaGVG1Ld5MBDuIfdlPnYa6ikeCfgw15XRvZ/EHyGYZNfgT1CcQr
         3WK+pspA7J1WNIiHPVncR4shFaOurQoedOLaZE6bDOZjbIt6QlAtZvOw0gAvaYK9Z4Bz
         97fg==
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
X-Gm-Message-State: AKS2vOwWaenNCOduiiorfL1laWgA6LJYy78BisCNpirEGvXQMKcYpHc2
	wYyUXeEWIaMZzfZq6MqdFnzbePdMyPtTicNXJp0JxQ==
X-Received: by 10.202.107.132 with SMTP id g126mr16274865oic.210.1499166451409;
        Tue, 04 Jul 2017 04:07:31 -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.202.64.84 with SMTP id n81csp830620oia;
        Tue, 4 Jul 2017 04:07:29 -0700 (PDT)
X-Received: by 10.28.35.201 with SMTP id j192mr26826785wmj.26.1499166449781;
        Tue, 04 Jul 2017 04:07:29 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1499166449; cv=none;
        d=google.com; s=arc-20160816;
        b=w44wsBCwG6WzFAidAqimJaO5Hhj+p2NDy3MNFZN2m4zzHw8IPANYkw0y1UzM8D6+vC
         am8MZnOdzzumIsOYjGApqKwFbPPb9A6ogPjThQYq4oQ8dSDTCiLrNLyTbm6Piuh6KmyZ
         LdwzOJ8Eu6noeyiJ+P9vuVo6PetNcf9jM9YSFJ7xSWVNvSQr2fPacshIY+dh9cdFd0Tx
         KbKF54FKTOPnd9bDcSQKf+nYLxdQxQyfzuEdtWDGfYX1P8d4EDi1MZJs5wXWrtPwqFh8
         nUvqng6KXeOHvDLGXtUezEPsVaIzdJFQBd3wnVYj9jjJ+fhox0trb6QP+RvMqmKbfQAA
         Ohbw==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=errors-to:sender:list-subscribe:list-help:list-post:list-archive
         :list-unsubscribe:list-id:precedence:subject:in-reply-to:references
         :to:mime-version:user-agent:from:date:message-id
         :arc-authentication-results;
        bh=r46d4JmKAPzJgegbTmuPT8DW/uWOr6gaBdDvIY560vU=;
        b=Co8xgtKNMWqyWduCijuSRDfqa14sXfzJOnQ0ibj4WcKJ1m5zDJ/xs/fnb29ZFrchRc
         4V/gr0Hv/9EMgxVcKmv98gRt7lOgoxSOO1qfTMoq8trRMy8/LbHdLvzAuf2b5zmToad9
         FdRXJsHR4Ll463Xq6t8WHRYlPhq3Vhq4y0SFvoXzVv84BrXZTowHvs0yEybLrXLPDYfx
         HHMCgSyxeKM8Tz8qHz+QbvS+e8JHpvkhTPgBNB7Euu+D5vfo0N/Es7fktOlgmji/UFnb
         ovctO8SLPQ00+GBe4m1ZypwWHnNOkuoz388kGMQuM4DB6R6xDgdEmSsBnXddNRae15yx
         bJNA==
ARC-Authentication-Results: i=1; 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
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 90si13720227wrf.313.2017.07.04.04.07.29;
        Tue, 04 Jul 2017 04:07:29 -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
Received: from [10.1.0.241] (localhost.localdomain [127.0.0.1])
	by lists.maptools.org (Postfix) with ESMTP id 3D33935C042;
	Tue,  4 Jul 2017 06:05:55 -0500 (EST)
Received: from polaris.osa.pri.ee (osa.pri.ee [213.219.84.188])
	by lists.maptools.org (Postfix) with ESMTP id 279EA35C023
	for <tiff@lists.maptools.org>; Tue,  4 Jul 2017 06:05:38 -0500 (EST)
Received: from localhost (localhost [127.0.0.1])
	by polaris.osa.pri.ee (Postfix) with ESMTP id A4CE06E6AA
	for <tiff@lists.maptools.org>; Tue,  4 Jul 2017 14:05:37 +0300 (EEST)
X-Virus-Scanned: amavisd-new at osa.pri.ee
Received: from polaris.osa.pri.ee ([127.0.0.1])
	by localhost (osa.pri.ee [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id epzV+DxmjXKK for <tiff@lists.maptools.org>;
	Tue,  4 Jul 2017 14:04:36 +0300 (EEST)
Received: from [0.0.0.0] (polaris.osa.pri.ee [213.219.84.188])
	(using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))
	(Client did not present a certificate)
	by polaris.osa.pri.ee (Postfix) with ESMTPSA id 069CE6E69A
	for <tiff@lists.maptools.org>; Tue,  4 Jul 2017 14:04:36 +0300 (EEST)
Message-ID: <595B7643.5040000@osa.pri.ee>
Date: Tue, 04 Jul 2017 14:04:35 +0300
From: Paavo Helde <paavo@osa.pri.ee>
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64;
	rv:25.8) Gecko/20151117 FossaMail/25.1.9
MIME-Version: 1.0
To: tiff@lists.maptools.org
References: <alpine.GSO.2.20.1705211423410.6623@freddy.simplesystems.org>
In-Reply-To: <alpine.GSO.2.20.1705211423410.6623@freddy.simplesystems.org>
Content-Type: multipart/mixed; boundary="------------090303050601020007080204"
Subject: [Tiff] A bug in libtiff error/warning handling
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

This is a multi-part message in MIME format.
--------------090303050601020007080204
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit


Hi,

I would like to report what I think is a bug in libtiff error and 
warning handling. There are two error handlers which can be installed 
(via TIFFSetErrorHandler and TIFFSetErrorHandlerExt) and which are 
called with a va_list. However, if both handlers are installed they will 
both iterate through the same va_list without reinitialization which is 
not allowed (seems to crash randomly with gcc on Linux, for example). I 
believe it should be the task of libtiff to reinitialize va_list between 
the calls. Ditto for warnings.

A patch file is attached, hopefully in a usable format.

Cheers
Paavo


--------------090303050601020007080204
Content-Type: text/plain; charset=windows-1252;
 name="TiffHandlerPatch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="TiffHandlerPatch"

Index: tif_warning.c
===================================================================
--- tif_warning.c	(revision 120569)
+++ tif_warning.c	(working copy)
@@ -51,12 +51,16 @@
 TIFFWarning(const char* module, const char* fmt, ...)
 {
 	va_list ap;
-	va_start(ap, fmt);
-	if (_TIFFwarningHandler)
+	if (_TIFFwarningHandler) {
+		va_start(ap, fmt);
 		(*_TIFFwarningHandler)(module, fmt, ap);
-	if (_TIFFwarningHandlerExt)
+		va_end(ap);
+	}
+	if (_TIFFwarningHandlerExt) {
+		va_start(ap, fmt);
 		(*_TIFFwarningHandlerExt)(0, module, fmt, ap);
-	va_end(ap);
+		va_end(ap);
+	}
 }
 
 void
@@ -63,12 +67,16 @@
 TIFFWarningExt(thandle_t fd, const char* module, const char* fmt, ...)
 {
 	va_list ap;
-	va_start(ap, fmt);
-	if (_TIFFwarningHandler)
+	if (_TIFFwarningHandler) {
+		va_start(ap, fmt);	
 		(*_TIFFwarningHandler)(module, fmt, ap);
-	if (_TIFFwarningHandlerExt)
+		va_end(ap);
+	}
+	if (_TIFFwarningHandlerExt) {
+		va_start(ap, fmt);
 		(*_TIFFwarningHandlerExt)(fd, module, fmt, ap);
-	va_end(ap);
+		va_end(ap);
+	}
 }
 
 
Index: tif_error.c
===================================================================
--- tif_error.c	(revision 120569)
+++ tif_error.c	(working copy)
@@ -51,12 +51,16 @@
 TIFFError(const char* module, const char* fmt, ...)
 {
 	va_list ap;
-	va_start(ap, fmt);
-	if (_TIFFerrorHandler)
+	if (_TIFFerrorHandler) {
+		va_start(ap, fmt);	
 		(*_TIFFerrorHandler)(module, fmt, ap);
-	if (_TIFFerrorHandlerExt)
+		va_end(ap);
+	}
+	if (_TIFFerrorHandlerExt) {
+		va_start(ap, fmt);
 		(*_TIFFerrorHandlerExt)(0, module, fmt, ap);
-	va_end(ap);
+		va_end(ap);
+	}
 }
 
 void
@@ -63,12 +67,16 @@
 TIFFErrorExt(thandle_t fd, const char* module, const char* fmt, ...)
 {
 	va_list ap;
-	va_start(ap, fmt);
-	if (_TIFFerrorHandler)
+	if (_TIFFerrorHandler) {
+		va_start(ap, fmt);
 		(*_TIFFerrorHandler)(module, fmt, ap);
-	if (_TIFFerrorHandlerExt)
+		va_end(ap);
+	}
+	if (_TIFFerrorHandlerExt) {
+		va_start(ap, fmt);
 		(*_TIFFerrorHandlerExt)(fd, module, fmt, ap);
-	va_end(ap);
+		va_end(ap);
+	}
 }
 
 /*

--------------090303050601020007080204
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

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