Return-Path: <awaresystems.be+caf_=filtered=awaresystems.be@gmail.com>
Delivered-To: filtered@awaresystems.be
Received: from mx05.one.com (mx05.one.com [195.47.247.76])
	by mail6.local (Postfix) with ESMTP id 3AC758014FAC3
	for <filtered@awaresystems.be>; Wed, 29 May 2013 21:14:07 +0200 (CEST)
X-Virus-Scanned: by one.com
X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "MIME-Version"
Received-SPF: pass (mx05: domain of awaresystems.be+caf_=filtered=awaresystems.be@gmail.com designates 209.85.215.42 as permitted sender)
X-Greylist: whitelisted by SQLgrey-1.8.0-rc2
Received: from mail-la0-f42.google.com (mail-la0-f42.google.com [209.85.215.42])
	by mx05.one.com (Postfix) with ESMTP id E44B53C1380
	for <filtered@awaresystems.be>; Wed, 29 May 2013 19:14:06 +0000 (UTC)
Received: by mail-la0-f42.google.com with SMTP id fg20so9079728lab.29
        for <filtered@awaresystems.be>; Wed, 29 May 2013 12:14:06 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=x-forwarded-to:x-forwarded-for:delivered-to:domainkey-status
         :x-gmail-fetch-info:delivered-to:x-virus-scanned:x-amavis-alert
         :x-greylist:x-env-sender:x-msg-ref:x-originating-ip
         :x-starscan-received:x-starscan-version:x-viruschecked:from:to
         :thread-topic:thread-index:date:message-id:accept-language
         :content-language:x-ms-has-attach:x-ms-tnef-correlator
         :x-originating-ip:mime-version:subject:x-beenthere:x-mailman-version
         :precedence:list-id:list-unsubscribe:list-archive:list-post
         :list-help:list-subscribe:content-type:mime-version:sender:errors-to;
        bh=wRMLeAAHlw+qyy28yYapM2yIDSTShaiDwlEurYeaX+w=;
        b=n96uwSXaRbWlvoVQm4sIVnB6hNvD00U02NKHD+XyVi/wnJurpbnOgX3cv4qJUwUAKf
         BAwAusOOdcP7eOpVNNJHqyePh+QtmGay5IIhfyvW2DzLb6jWGYl1OwNAB5yNI7v5Wr0F
         QujsLs2F8txEpgrc8uXftnMMJE7BRCGgKhMtmxV+tjPPKsBAFpdwy8azxV8W1NnNmZkQ
         n7AENMzzpTRc3vmYVdsrwtJZTTDdXYd1oWT4JNvnMjYzdOpARe3Sj1BaQd85ZhRdqPXz
         J/y4SBLNND5s5Zo0fyTojZztzbw/R/oCMiYqp6KuLaK9zgqnQtpCNjtH8qPJ+wQW1WvN
         rJoA==
X-Received: by 10.112.156.164 with SMTP id wf4mr2195757lbb.76.1369854846377;
        Wed, 29 May 2013 12:14:06 -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.114.82.70 with SMTP id g6csp55533ldy;
        Wed, 29 May 2013 12:14:05 -0700 (PDT)
X-Received: by 10.152.29.227 with SMTP id n3mr2099249lah.3.1369854844905;
        Wed, 29 May 2013 12:14:04 -0700 (PDT)
DomainKey-Status: bad format
Received-SPF: neutral (google.com: 91.198.169.49 is neither permitted nor denied by best guess record for domain of tiff-bounces@lists.maptools.org) client-ip=91.198.169.49;
Received: by 10.112.34.74 with POP3 id x10mf9909lbi.31;
        Wed, 29 May 2013 12:14:04 -0700 (PDT)
X-Gmail-Fetch-Info: info@awaresystems.be 1 pop.awaresystems.be 110 info@awaresystems.be
Delivered-To: info@awaresystems.be
Received: from mx-b.one.com (mx-b.one.com [91.198.169.49])
	by mail6.local (Postfix) with ESMTP id E4B058014FAC3
	for <info@awaresystems.be>; Wed, 29 May 2013 20:22:36 +0200 (CEST)
X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "MIME-Version"
X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0-rc2
Received: from lists.maptools.org (ks365428.kimsufi.com [94.23.4.142])
	by mx-b.one.com (Postfix) with ESMTP id 9E7E81ED8D2
	for <info@awaresystems.be>; Wed, 29 May 2013 18:22:16 +0000 (UTC)
Received: from [10.1.0.241] (localhost.localdomain [127.0.0.1])
	by lists.maptools.org (Postfix) with ESMTP id 5EBAE35C02A;
	Wed, 29 May 2013 13:21:05 -0500 (EST)
Received: from mail1.bemta7.messagelabs.com (mail1.bemta7.messagelabs.com
	[216.82.254.102])
	by lists.maptools.org (Postfix) with ESMTPS id 5180435C02A
	for <tiff@lists.maptools.org>; Wed, 29 May 2013 13:20:13 -0500 (EST)
Received: from [216.82.254.51:61618] by server-6.bemta-7.messagelabs.com id
	DF/06-04918-CD646A15; Wed, 29 May 2013 18:20:12 +0000
X-Env-Sender: ALAVIOLETTE@overwatch.textron.com
X-Msg-Ref: server-5.tower-144.messagelabs.com!1369851610!4719480!1
X-Originating-IP: [20.132.69.61]
X-StarScan-Received: 
X-StarScan-Version: 6.9.6; banners=-,-,-
X-VirusChecked: Checked
Received: (qmail 12202 invoked from network); 29 May 2013 18:20:11 -0000
Received: from unknown (HELO TXAINFNWH047.ent.textron.com) (20.132.69.61)
	by server-5.tower-144.messagelabs.com with DHE-RSA-AES256-SHA encrypted
	SMTP; 29 May 2013 18:20:11 -0000
Received: from txaappnwh054.ent.textron.com (unknown [10.244.250.23]) by
	TXAINFNWH047.ent.textron.com with smtp
	id 69ba_396e_f1c82d06_3f96_4c18_a7cd_4ca9bfd0dcc3;
	Wed, 29 May 2013 14:23:57 -0400
Received: from localhost (localhost.localdomain [127.0.0.1])
	by txaappnwh054.ent.textron.com (postfix) with ESMTP id 55A8B808B38
	for <tiff@lists.maptools.org>; Wed, 29 May 2013 14:20:07 -0400 (EDT)
Received: from TXAMASNWH024.ent.textron.com (txamasnwh024.ent.textron.com
	[10.244.221.24]) by txaappnwh054.ent.textron.com (postfix) with ESMTP
	for <tiff@lists.maptools.org>; Wed, 29 May 2013 14:20:06 -0400 (EDT)
Received: from TXAMASNWH023.ent.textron.com ([169.254.2.232]) by
	TXAMASNWH024.ent.textron.com ([169.254.7.51]) with mapi id
	14.02.0309.002; Wed, 29 May 2013 14:20:06 -0400
From: "LaViolette, Alan" <ALAVIOLETTE@overwatch.textron.com>
To: "tiff@lists.maptools.org" <tiff@lists.maptools.org>
Thread-Topic: LibTiff Bug in ChopUpSingleUncompressedStrip
Thread-Index: Ac5cmSRXuFu65rF6QAW7Dwn3b+UeOA==
Date: Wed, 29 May 2013 18:20:05 +0000
Message-ID: <6725AFBCB5D0E6429DC7D90EBBDBF7A2139C887D@TXAMASNWH023.ent.textron.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-originating-ip: [10.244.221.232]
MIME-Version: 1.0
Subject: [Tiff] LibTiff Bug in ChopUpSingleUncompressedStrip
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: multipart/mixed; boundary="===============1259257885=="
Mime-version: 1.0
Sender: tiff-bounces@lists.maptools.org
Errors-To: tiff-bounces@lists.maptools.org

--===============1259257885==
Content-Language: en-US
Content-Type: multipart/alternative;
	boundary="_000_6725AFBCB5D0E6429DC7D90EBBDBF7A2139C887DTXAMASNWH023ent_"

--_000_6725AFBCB5D0E6429DC7D90EBBDBF7A2139C887DTXAMASNWH023ent_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

I have found an issue in ChopUpSingleUncompressedStrip() located in tif_dir=
read.c .  This function attempts to split up a large single strip image int=
o multiple strips.  I believe the issue I am having is it does not reset/ch=
ange the td->td_stripbufmax value to represent the new size of the size and=
 offset blocks.  This causes the code in _TIFFGetByteCount() and _TIFFGetOf=
fset() to incorrectly compute the correct block number (it should now alway=
s be 0), It will only work for images with < td_stripbufmax strips, in my c=
ase 1024.

Code in _TIFFGetByteCount():

extern uint32
_TIFFGetByteCount(TIFF* tif, tstrip_t strip)
{
      TIFFDirectory *td =3D &tif->tif_dir;
      int   status =3D 1;
      uint32      blkno =3D strip / td->td_stripbufmax;  // Value is not se=
t correctly
      uint32      tdi;
...

Code as it needs to be in ChopUpSingleUncompressedStrip():
      td->td_stripbcsbuf =3D newcounts;
      td->td_stripoffsbuf =3D newoffsets;
      td->td_stripbcsblk =3D 0;
      td->td_stripoffsblk =3D 0;
      td->td_stripbytecountsorted =3D 1;
      td->td_stripbufmax =3D nstrips;             // New assignment to td_s=
tripbufmax


I have tested this change in my own code base and it is working correctly, =
but I don't know if it will have any other effects.  Also other td_strip* v=
alues are not adjusted in ChopUpSingleUncompressedStrip(), is that Ok.

Thanks,
Alan L.

--_000_6725AFBCB5D0E6429DC7D90EBBDBF7A2139C887DTXAMASNWH023ent_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
>
<meta name=3D"Generator" content=3D"Microsoft Word 12 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
	{font-family:Wingdings;
	panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:Inconsolata;
	panose-1:2 11 6 9 3 0 3 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:purple;
	text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
	{mso-style-priority:34;
	margin-top:0in;
	margin-right:0in;
	margin-bottom:0in;
	margin-left:.5in;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";}
span.EmailStyle17
	{mso-style-type:personal-compose;
	font-family:"Calibri","sans-serif";
	color:windowtext;}
.MsoChpDefault
	{mso-style-type:export-only;}
@page WordSection1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
	{page:WordSection1;}
/* List Definitions */
@list l0
	{mso-list-id:933710832;
	mso-list-type:hybrid;
	mso-list-template-ids:480441374 -701079120 67698691 67698693 67698689 6769=
8691 67698693 67698689 67698691 67698693;}
@list l0:level1
	{mso-level-start-at:0;
	mso-level-number-format:bullet;
	mso-level-text:-;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;
	font-family:"Calibri","sans-serif";
	mso-fareast-font-family:Calibri;
	mso-bidi-font-family:"Times New Roman";}
ol
	{margin-bottom:0in;}
ul
	{margin-bottom:0in;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=3D"EN-US" link=3D"blue" vlink=3D"purple">
<div class=3D"WordSection1">
<p class=3D"MsoNormal">I have found an issue in ChopUpSingleUncompressedStr=
ip() located in tif_dirread.c .&nbsp; This function attempts to split up a =
large single strip image into multiple strips.&nbsp; I believe the issue I =
am having is it does not reset/change the td-&gt;td_stripbufmax
 value to represent the new size of the size and offset blocks.&nbsp; This =
causes the code in _TIFFGetByteCount() and _<i>TIFFGetOffset() to incorrect=
ly compute the correct block number (it should now always be 0), It will on=
ly work for images with &lt; td</i>_stripbufmax
 strips, in my case 1024.<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">Code in _TIFFGetByteCount():<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-fa=
mily:Inconsolata;color:blue">extern</span><span style=3D"font-family:Incons=
olata">
<span style=3D"color:#010001">uint32<o:p></o:p></span></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-fa=
mily:Inconsolata;color:#010001">_TIFFGetByteCount</span><span style=3D"font=
-family:Inconsolata">(<span style=3D"color:#010001">TIFF</span>*
<span style=3D"color:#010001">tif</span>, <span style=3D"color:#010001">tst=
rip_t</span>
<span style=3D"color:#010001">strip</span>)<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-fa=
mily:Inconsolata">{<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-fa=
mily:Inconsolata">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<span style=3D"color:#010001">TIFFDirectory</span> *<span style=3D"color:#0=
10001">td</span> =3D &amp;<span style=3D"color:#010001">tif</span>-&gt;<spa=
n style=3D"color:#010001">tif_dir</span>;<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-fa=
mily:Inconsolata">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<span style=3D"color:blue">int</span>&nbsp;&nbsp; <span style=3D"color:#010=
001">status</span> =3D 1;<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-fa=
mily:Inconsolata">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<span style=3D"color:#010001">uint32</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <=
span style=3D"color:#010001">blkno</span> =3D
<span style=3D"color:#010001">strip</span> / <b><span style=3D"color:#01000=
1">td</span>-&gt;<span style=3D"color:#010001">td_stripbufmax</span></b>;&n=
bsp; // Value is not set correctly<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-fa=
mily:Inconsolata">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<span style=3D"color:#010001">uint32</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <=
span style=3D"color:#010001">tdi</span>;<o:p></o:p></span></p>
<p class=3D"MsoNormal">&#8230;<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">Code as it needs to be in ChopUpSingleUncompressedSt=
rip():<o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-fa=
mily:Inconsolata">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<span style=3D"color:#010001">td</span>-&gt;<span style=3D"color:#010001">t=
d_stripbcsbuf</span> =3D
<span style=3D"color:#010001">newcounts</span>;<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-fa=
mily:Inconsolata">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<span style=3D"color:#010001">td</span>-&gt;<span style=3D"color:#010001">t=
d_stripoffsbuf</span> =3D
<span style=3D"color:#010001">newoffsets</span>;<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-fa=
mily:Inconsolata">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<span style=3D"color:#010001">td</span>-&gt;<span style=3D"color:#010001">t=
d_stripbcsblk</span> =3D 0;<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-fa=
mily:Inconsolata">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<span style=3D"color:#010001">td</span>-&gt;<span style=3D"color:#010001">t=
d_stripoffsblk</span> =3D 0;<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-fa=
mily:Inconsolata">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<span style=3D"color:#010001">td</span>-&gt;<span style=3D"color:#010001">t=
d_stripbytecountsorted</span> =3D 1;<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"text-autospace:none"><span style=3D"font-fa=
mily:Inconsolata">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<b><span style=3D"color:#010001">td</span>-&gt;<span style=3D"color:#010001=
">td_stripbufmax</span> =3D
<span style=3D"color:#010001">nstrips</span></b>;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // New assignment to td_stri=
pbufmax<o:p></o:p></span></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">I have tested this change in my own code base and it=
 is working correctly, but I don&#8217;t know if it will have any other eff=
ects.&nbsp; Also other td_strip* values are not adjusted in ChopUpSingleUnc=
ompressedStrip(), is that Ok.<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">Thanks,<o:p></o:p></p>
<p class=3D"MsoNormal">Alan L.<o:p></o:p></p>
</div>
</body>
</html>

--_000_6725AFBCB5D0E6429DC7D90EBBDBF7A2139C887DTXAMASNWH023ent_--

--===============1259257885==
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/
--===============1259257885==--
