Return-Path: <awaresystems.be+caf_=filtered=awaresystems.be@gmail.com>
Delivered-To: filtered@awaresystems.be
Received: from mx5.public.one.com ([10.246.18.25])
	by mail6.local.one.com (Dovecot) with LMTP id HZYUM1sWg1mIYAEAsyOMew
	for <filtered@awaresystems.be>; Thu, 03 Aug 2017 15:06:42 +0000
X-HalOne-ID: 5a1ff265-785d-11e7-bb21-b82a72d82f61
Received: from mail-oi0-f52.google.com (unknown [209.85.218.52])
	by mx5.public.one.com (Halon) with ESMTPS
	id 5a1ff265-785d-11e7-bb21-b82a72d82f61;
	Thu, 03 Aug 2017 15:06:40 +0000 (UTC)
Received: by mail-oi0-f52.google.com with SMTP id x3so15239827oia.1
        for <filtered@awaresystems.be>; Thu, 03 Aug 2017 08:06:40 -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=oTZ7lN6z37LLlmiGZ5tUfEVOGEdgRGABalOeQAfMk/0=;
        b=Y2RUI7XONbVns9PIz4RZnvxZ3ErMKc4ACCO5OzUgwdxKqFGzaLKMF+T474HiW1V0a+
         KzUSpJV5yAsZB6TUnQiLy9dLDYDiaWk4brVP2hWqJWiu4+4U9YESdnhO167bp3NwxrDh
         oodGj9sy2zu6auchvji9ylcHmxn6lcgEZvZpgx9iE6gfE1c7dfpiiCmU0IAeiQAi5Xpt
         VImrnh2uyCRoWZr+RfeQEB2x8xx9wWhxH370hAMboT3L3pbxCN2CjoyD8YxQS/sxD3Y3
         Qiqf6XvtZKJu0UxahUkbVAvnAPAfUFi6XHAK4LpyufJ5Y9oldx914TGyciYQNYHWTRMs
         SrRQ==
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: AIVw112sgGtJFbMWQ67844JUWnrTZ+GSRdSelVQDc1V9L5cw5xtSkX76
	4pr2hFmR85p8I++zCrbXkDp/GRfrTVgRIwhhIdDPxQ==
X-Received: by 10.202.235.19 with SMTP id j19mr2039733oih.15.1501772799113;
        Thu, 03 Aug 2017 08:06:39 -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.68.1 with SMTP id o1csp902878ooa;
        Thu, 3 Aug 2017 08:06:37 -0700 (PDT)
X-Received: by 10.28.193.138 with SMTP id r132mr1309178wmf.155.1501772797799;
        Thu, 03 Aug 2017 08:06:37 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1501772797; cv=none;
        d=google.com; s=arc-20160816;
        b=XsTbcvCkCQSurdzDBPiY8SxNDjgr5uVdFd45zLZqB5sHyoTBHwVizK8bVmZFSxwxtG
         +4OkquFBWK4kwzTY3nVjhVFxmHBvyaLG7gykbb7Xhl2XBkckjQaDP1Eu0WRGEMSjXxef
         DsMWu5mjfOuGEL2FnBtbyqStRPnccG+pJKGQ18F1SjLozjEHZuLQvyvXPG/6gzDFD7RE
         2gwOx4aqgVc7JONVEL3Or0UCojUrKrfSeJCPpm5GzkLwpBicPTp57jlTvP22mIDvKq5/
         H3fJrfZvfq9eZtYwXM9LlJlreVj3zy5eQmXdJ//zQUhNbhV85KSOj8ap4xB0oj3iOzXN
         KoFw==
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=oTZ7lN6z37LLlmiGZ5tUfEVOGEdgRGABalOeQAfMk/0=;
        b=FOt6aXu+nyhUUiXubv3kT7AXGagsoaxP+yCVz+zZWEl7Y3wIY69b60gqTqP95mwDjN
         dSfCnxpAZIO8StEZ9TctEOaCZ68UtAj0ecvPyXe7IiQEuF2SR+rV67Oh7L21qS3hupIB
         KnrgcC6Fr9DxUNFiytj+Vk+Sk+os0V2wCCIkcdhl1LnIC9WbFJKIZbx1lz9+KAo2hDpD
         HosJ5h0Tt+kkK+tmi6Xsxod8HE1ItEhItTxRiZLer+PcGFZ5SvBAzdMnMtgmL+7+62SL
         Mvbm16xR9jIHeDt8YxmhSSRnnhPggQFbi4BdgbSsnxwK5vdcQxgtAxjebsmp7VvYJpbE
         JA2g==
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 e10si1750835wre.332.2017.08.03.08.06.37;
        Thu, 03 Aug 2017 08:06:37 -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 73AE135C035;
	Thu,  3 Aug 2017 10:05:33 -0500 (EST)
Received: from mail-qk0-f169.google.com (mail-qk0-f169.google.com
	[209.85.220.169])
	by lists.maptools.org (Postfix) with ESMTPS id 4B63735C02E
	for <tiff@lists.maptools.org>; Thu,  3 Aug 2017 10:05:17 -0500 (EST)
Received: by mail-qk0-f169.google.com with SMTP id x191so9068465qka.5
	for <tiff@lists.maptools.org>; Thu, 03 Aug 2017 08:05:17 -0700 (PDT)
X-Received: by 10.55.150.133 with SMTP id y127mr2937481qkd.200.1501772715750; 
	Thu, 03 Aug 2017 08:05:15 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.12.185.153 with HTTP; Thu, 3 Aug 2017 08:04:55 -0700 (PDT)
In-Reply-To: <alpine.GSO.2.20.1708021019070.287@scrappy.simplesystems.org>
References: <CABoQFUD-RYPQeJSCBPVdXNeA-yESnHH1QcySUPd3QA=SxMcOOA@mail.gmail.com>
	<alpine.GSO.2.20.1708021019070.287@scrappy.simplesystems.org>
From: Nicolas RUFF <nicolas.ruff@gmail.com>
Date: Thu, 3 Aug 2017 17:04:55 +0200
Message-ID: <CABoQFUCwG6Nb7GNwkU1xp-jdUP2eeEqWdGoYXkHs2t2fJzc2GA@mail.gmail.com>
To: Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
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

> It seems best to block any negative size values from being passed into these
> functions in the first place.  Libtiff is not in control of the I/O
> functions, so it is best to assure that they are not passed illegal values
> which might cause I/O implementations to do very bad things.

Not sure to understand what you mean here. Here are all call locations
for SeekOK():
tif_dir.c : 2 times
tif_read.c : 4 times
tif_write.c : 1 time
tif_dirread.c : 3 times
tif_dirwrite.c : 9 times

Do you suggest to add an extra check for (off<0) before each call? If
yes, I can prepare a patch.

Also, is there any chance that TIFFSeekFile() could legitimately be
called with off<0 and whence=SEEK_CUR? I mean, is there any reason to
seek backward in a TIFF file? Looking at the code, the only calls to
TIFFSeekFile(whence=SEEK_CUR) take (dircount*object_size) as an offset
and should therefore always be positive, but I am not super-familiar
with TIFF format(s).

Thank you,
- Nicolas RUFF
_______________________________________________
Tiff mailing list: Tiff@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
