Return-Path: <awaresystems.be+caf_=filtered=awaresystems.be@gmail.com>
Delivered-To: filtered@awaresystems.be
Received: from mx2.public.one.com ([10.246.18.22])
	by mail6.local.one.com (Dovecot) with LMTP id 8ljyG6Tkr1lLbwAAsyOMew
	for <filtered@awaresystems.be>; Wed, 06 Sep 2017 13:18:29 +0000
X-HalOne-ID: deb524c5-9305-11e7-896d-b82a72d88088
Received: from mail-oi0-f50.google.com (unknown [209.85.218.50])
	by mx2.public.one.com (Halon) with ESMTPS
	id deb524c5-9305-11e7-896d-b82a72d88088;
	Wed, 06 Sep 2017 13:18:28 +0000 (UTC)
Received: by mail-oi0-f50.google.com with SMTP id r20so12416711oie.0
        for <filtered@awaresystems.be>; Wed, 06 Sep 2017 06:18:28 -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
         :mime-version:in-reply-to:references:from:date:message-id:to:cc
         :subject:precedence:list-id:list-unsubscribe:list-archive:list-post
         :list-help:list-subscribe:content-transfer-encoding:sender:errors-to;
        bh=prGN6DbQSRft5Wqu+HNb+/RuR6COX9Z/K73IYuCDJhE=;
        b=cW0JObl7OxGL/COzmtv9FLV4NuQ3re1u8zRMJveYAchr7e5+3cJRfItigvOouOp2hq
         6Fp0skOl7PU/XD+gaY2T5a/X07/qex1rlsuaIzqb2bGnjUeD9BqvYLFjUSA8XxHa4KBn
         Ah680IsbAxnAGbHgzaNQObTNt0alI+bACqm1P1Y4gjbJIbTRjqmnvpJUjdrbFEOh6BLq
         J63xUmVyYo7H9zCz7sc1BN9h2tfGaJevZVrDahh+LIwtn+/FiQx0K/8eboIdAZOUoVBd
         B/+LIxAJvbzhSKZ1tqgzXn5gkeMMveMdZ4q6jDtCndTmfomZNGtpSGLq+CipgrB/X9dd
         7FvA==
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 sp=NONE dis=NONE) header.from=gmail.com
X-Gm-Message-State: AHPjjUiQF3OkxCzSoFLNnvS8QpyevqxX70pz04O2nJ3b5ZN1O3h2V7Jo
	X5aZpf/lSy8Aizsie/FImp/UaO9XoEMYRtlI7bwL2g==
X-Received: by 10.202.73.65 with SMTP id w62mr2576879oia.159.1504703907379;
        Wed, 06 Sep 2017 06:18:27 -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.74.90.4 with SMTP id v4csp845362ooa;
        Wed, 6 Sep 2017 06:18:25 -0700 (PDT)
X-Received: by 10.28.66.157 with SMTP id k29mr60299wmi.127.1504703905128;
        Wed, 06 Sep 2017 06:18:25 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1504703905; cv=none;
        d=google.com; s=arc-20160816;
        b=m6l1ONJKbN/9CK+3ov0ZIWkquqGsBdOm5e79STlcAyqFNxrdDJTCNj9FOQ6rPp6akz
         KQKQELpacFk8jmRku8+mVadUgorCRHKeGh8vWUdR4UD9NsVxTmnYLecpwbSJSvHf9ZDz
         PKiAMRh/gdrA7KomdiO/AjM/nqSfoiMuU4/BJk7NoNr5hv84Gde9vqUBun4rpwAJqo3u
         GNLVHernMsXRu5Fg3zAqqP5HpS4G39iC5NwCzG4awLqWpouS1DEb/ZJmSYDXp8ZHs+hX
         hWhZQ915NPYvZa030u+WYy234pBvA3stofW6ScRjrlz/CqB4cXojnOYp52AqnRQRtr5u
         VfiQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help
         :list-post:list-archive:list-unsubscribe:list-id:precedence:subject
         :cc:to:message-id:date:from:references:in-reply-to:mime-version
         :arc-authentication-results;
        bh=prGN6DbQSRft5Wqu+HNb+/RuR6COX9Z/K73IYuCDJhE=;
        b=g6s16u5eP5ck1UDEg05N6RCbbWxyvP/OvMOzCJ/72ynQESSuit3b8bvcKyKp2yCstJ
         Kjq2djphOaSVPfP0SoJxC9ZehlPwV9SQqopJlOr9ZAFqoXCZc+HlEIk9HnnCvIdIjuqn
         J5U/2swxaSpieQ/USCq8KYWpYdvSUghI2tMNVGYv9SFIxFdJYC7UOQ5jNIU7V1ifOYwz
         7LQacNOLFu3LtXB/UAxNPJXKQsi27NDtHVFgJxNm6fciI76ZEy2mT7Jc2q2qvLjA30Z/
         3yLC6NkNkO2zFhBIbbObFFa+ESBF/igLxAbf2Srw+VAMGlG6ZdsvX6cTwYFoga3N0OTu
         /4EA==
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;
       dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com
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 f72si1182765wme.151.2017.09.06.06.18.24;
        Wed, 06 Sep 2017 06:18:25 -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 sp=NONE dis=NONE) header.from=gmail.com
Received: from [10.1.0.241] (localhost.localdomain [127.0.0.1])
	by lists.maptools.org (Postfix) with ESMTP id 2512535C046;
	Wed,  6 Sep 2017 08:17:23 -0500 (EST)
Received: from mail-wr0-f182.google.com (mail-wr0-f182.google.com
	[209.85.128.182])
	by lists.maptools.org (Postfix) with ESMTPS id 8C74535C044
	for <tiff@lists.maptools.org>; Wed,  6 Sep 2017 08:16:28 -0500 (EST)
Received: by mail-wr0-f182.google.com with SMTP id a47so12059298wra.1
	for <tiff@lists.maptools.org>; Wed, 06 Sep 2017 06:16:28 -0700 (PDT)
X-Google-Smtp-Source: ADKCNb5SR4Aw+RfFSuWqzPMqIBQjtdoX48uQ31SS0Y420i71oKeTWDJTs2xQW9Zjl2UqnTc7juWVKTw2prPbEn5Gaoc=
X-Received: by 10.223.147.39 with SMTP id 36mr1628553wro.175.1504703787186;
	Wed, 06 Sep 2017 06:16:27 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.28.18.207 with HTTP; Wed, 6 Sep 2017 06:16:06 -0700 (PDT)
In-Reply-To: <3569965.Ji6WjG8THA@even-i700>
References: <CABoQFUD-RYPQeJSCBPVdXNeA-yESnHH1QcySUPd3QA=SxMcOOA@mail.gmail.com>
	<CABoQFUA7iVan8dC-iNjm6H=K9AudhXXB3TFOsWdLvqskP0_9KA@mail.gmail.com>
	<CABoQFUA6LvZitv8HgQR1W-HNWQpqfgenu1KCXXMWQ9qT--Bvww@mail.gmail.com>
	<3569965.Ji6WjG8THA@even-i700>
From: Nicolas RUFF <nicolas.ruff@gmail.com>
Date: Wed, 6 Sep 2017 15:16:06 +0200
Message-ID: <CABoQFUDs0ZVv58ox4AKcRMOp8nByVWzTb3wHSL9XEc_0uKmZJw@mail.gmail.com>
To: Even Rouault <even.rouault@spatialys.com>
Cc: tiff@lists.maptools.org
Subject: Re: [Tiff] Error handling in Read/Write/Seek
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

> One potential issue I can see is that we use off_t here, which isn't
> necessarily what is use in the implementation of the file system callbacks.
> For example tif_unix.c uses _TIFF_off_t. I'm wondering for example if off_t
> might not be 32 bit only in some circumstances when evaluated in libtiff
> non-IO code.

Indeed off_t is 32-bit on 32-bit Linux systems.

TIFFSeekProc is typedef'ed to (thandle_t, toff_t, int).

And toff_t is an alias for uint64, regardless of the platform (from tiffio.h).

tif_unix.c implementation adheres to this type definition:
_tiffSeekProc(thandle_t fd, uint64 off, int whence)

So the proper patch should be:

- (TIFFSeekFile((tif),(off),SEEK_SET)==(off))
+ (((int64)(off) >= 0) && TIFFSeekFile((tif),(off),SEEK_SET)==(off))

Thank you for catching this!
_______________________________________________
Tiff mailing list: Tiff@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
