Return-Path: <tiff-bounces@lists.osgeo.org>
Delivered-To: even.rouault@spatialys.com
Received: from spool.mail.gandi.net (spool5.mail.gandi.net [217.70.178.214])
	by nmboxes134.sd4.0x35.net (Postfix) with ESMTP id A3BEB61859
	for <even.rouault@spatialys.com>; Tue, 22 Jan 2019 15:11:40 +0000 (UTC)
Received: from lists.osgeo.org (osgeo6.osgeo.osuosl.org [140.211.15.3])
	by spool.mail.gandi.net (Postfix) with ESMTPS id B1A90D80DAD
	for <even.rouault@spatialys.com>; Tue, 22 Jan 2019 15:11:33 +0000 (UTC)
Received: from osgeo6.osgeo.osuosl.org (localhost [127.0.0.1])
	by lists.osgeo.org (Postfix) with ESMTP id 250DF614665D;
	Tue, 22 Jan 2019 07:11:31 -0800 (PST)
Received: from mail-it1-f174.google.com (mail-it1-f174.google.com
 [209.85.166.174])
 by lists.osgeo.org (Postfix) with ESMTPS id AA816614664A
 for <tiff@lists.osgeo.org>; Tue, 22 Jan 2019 07:11:29 -0800 (PST)
Received: by mail-it1-f174.google.com with SMTP id g85so21900735ita.3
 for <tiff@lists.osgeo.org>; Tue, 22 Jan 2019 07:11:29 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=mime-version:from:date:message-id:subject:to;
 bh=EXzBQqv8ScXZ17aZ7FXQxCVKQ518mZan/cg65krDGAU=;
 b=evENUS4goBEKp0q5C/n0LMwflOBMeJfH4IYKy3z6mGFgMU7FpSIvtllG4LtRGdSSSQ
 9V1Ydt0YmQXR9NNX/QUTshhPKvpjfvsKGIsemNRoLvpeU9cYVhgksiRVF7sMf0pbVCqv
 JgjEIwQvTVeNp1cDQQU8yjOiRp8QR1MNiPBi9TQcMQFuNrcOHL0aYa5loRC9/2ymx9hZ
 1OwCIzb+2sdhPBbCExnKKewvZS2UfDSNr6xXoS+mKextajXYu9rtZHq6Qjzhwb5wlaHW
 Q8pLgkj76w0kDRWDByQT85PMizIs8SFO9P5BZE9OJt3eIOkvtfBhPSs4nhguhXydnDwq
 HXuw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
 bh=EXzBQqv8ScXZ17aZ7FXQxCVKQ518mZan/cg65krDGAU=;
 b=CvPjqs10hEhNzpezcw3N+dM4otvbUeBYszs7uxkA9+U8vp/5BdJzC3aiEKouaPTc4r
 lTR3mtKRyn8ooZNkHn0JxCnHyzVgUEVkAPJNglJlePlldiBGuXodNeHbfk2rOw7z12Vr
 QFkKpTbTYBx1gHswnAZMbVHLxuuiCUenufIg5BgB07C/o1Do/bSgcj4yqIA+Py8dT3pY
 qSKrOK5hckamEj3KI7kta1LZibYRCp6gUgNKuJDytd7UV2PqK9FLXjzrVDIHyXNYQPsv
 +h0rjNQP3Lgy8xiPUR89QQFKaP8zUQ7gDxwHiAe4X294/fHNQFgd906vMtwhZDV50bKf
 K+jw==
X-Gm-Message-State: AJcUukfnkLO2aJYt2a8VUjAia6yulHv6VjG0cMI9hyVEyGHYETNgWhGr
 VmGtwQM86PSgVTITTSRWEJZw/jlhu4EKCgOGqLZnVc0=
X-Google-Smtp-Source: ALg8bN4PNKtBl/YdUTvxkOLHvqCm8MWoHwa9sJ7VnqjWT8aKv3SdQ14UVQxbe8uPggFd/uVWmX+S78AS9gZC4Tg1P+w=
X-Received: by 2002:a24:68d2:: with SMTP id v201mr2165931itb.112.1548169888678; 
 Tue, 22 Jan 2019 07:11:28 -0800 (PST)
MIME-Version: 1.0
From: SM <skypemesm@gmail.com>
Date: Tue, 22 Jan 2019 10:11:17 -0500
Message-ID: <CAKSvmhY-mLmSR2zUZBNz0D-Kc7G687cjBXqDzcJHZRMadC=PRA@mail.gmail.com>
To: tiff@lists.osgeo.org
Subject: [Tiff] Possible bug in libTiff 4.0.9?
X-BeenThere: tiff@lists.osgeo.org
X-Mailman-Version: 2.1.20
Precedence: list
List-Id: TIFF and libtiff discussion <tiff.lists.osgeo.org>
List-Unsubscribe: <https://lists.osgeo.org/mailman/options/tiff>,
 <mailto:tiff-request@lists.osgeo.org?subject=unsubscribe>
List-Post: <mailto:tiff@lists.osgeo.org>
List-Help: <mailto:tiff-request@lists.osgeo.org?subject=help>
List-Subscribe: <https://lists.osgeo.org/mailman/listinfo/tiff>,
 <mailto:tiff-request@lists.osgeo.org?subject=subscribe>
Content-Type: multipart/mixed; boundary="===============4666756469027123478=="
Errors-To: tiff-bounces@lists.osgeo.org
Sender: "Tiff" <tiff-bounces@lists.osgeo.org>
X-GND-Status: LEGIT

--===============4666756469027123478==
Content-Type: multipart/alternative; boundary="00000000000044462005800d64cd"

--00000000000044462005800d64cd
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hello,



I have upgraded to TIFF 4.0.9 from 4.0.0 and I saw the following change in
tif_write.c:

https://gitlab.kitware.com/third-party/tiff/commit/f0dd74c5e33be1f7f98a3b8d=
37cc71a889db9fe6?view=3Dparallel

which fixes tif_encodestrip() and it returns -1 in case of failure as
documented.



I believe this fix might have uncovered another bug in the library. I came
across a special case while writing a YCbCr image which is JPEG compressed
and contains a partial strip. The last strip could not be encoded
successfully. I found that the failure is occurring in jpeg_write_raw_data
in the JPEG library. It seems that the cinfo structure passed to the JPEG
library from TIFF library contains incorrect dimensions of the strip if it
is partial.

The buffer that is being passed to the library is of the same size as the
whole strip (even in the case of a partial strip). In case of a partial
strip, the rest of the buffer is filled with zeros.



Image details to be written:

'ImageWidth' - 3008

=E2=80=98ImageLength=E2=80=99 - 1952

'Photometric' - YCbCr

'Compression' - JPEG

'BitsPerSample' - 8

'SamplesPerPixel' - 3

=E2=80=98SampleFormat', - UInt

'PlanarConfiguration' - Chunky

'RowsPerStrip' - 256

'YCbCrSubSampling' - [2 1]



Can you please confirm if it is a bug?


Thanks,

Upanita

--00000000000044462005800d64cd
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><p class=3D"MsoNormal" style=3D"margin:0in 0in 0.0001pt;fo=
nt-size:11pt;font-family:Calibri,sans-serif"><span style=3D"font-size:11pt"=
>Hello,</span><br></p>

<p class=3D"MsoNormal" style=3D"margin:0in 0in 0.0001pt;font-size:11pt;font=
-family:Calibri,sans-serif">=C2=A0</p>

<p class=3D"MsoNormal" style=3D"margin:0in 0in 0.0001pt;font-size:11pt;font=
-family:Calibri,sans-serif">I have upgraded to TIFF 4.0.9 from 4.0.0 and I =
saw the
following change in tif_write.c:</p>

<p class=3D"MsoNormal" style=3D"margin:0in 0in 0.0001pt;font-size:11pt;font=
-family:Calibri,sans-serif"><a href=3D"https://gitlab.kitware.com/third-par=
ty/tiff/commit/f0dd74c5e33be1f7f98a3b8d37cc71a889db9fe6?view=3Dparallel" st=
yle=3D"color:rgb(5,99,193)">https://gitlab.kitware.com/third-party/tiff/com=
mit/f0dd74c5e33be1f7f98a3b8d37cc71a889db9fe6?view=3Dparallel</a></p>

<p class=3D"MsoNormal" style=3D"margin:0in 0in 0.0001pt;font-size:11pt;font=
-family:Calibri,sans-serif">which fixes tif_encodestrip() and it returns -1=
 in case of
failure as documented.</p>

<p class=3D"MsoNormal" style=3D"margin:0in 0in 0.0001pt;font-size:11pt;font=
-family:Calibri,sans-serif">=C2=A0</p>

<p class=3D"MsoNormal" style=3D"margin:0in 0in 0.0001pt;font-size:11pt;font=
-family:Calibri,sans-serif">I believe this fix might have uncovered another=
 bug in the
library. I came across a special case while writing a YCbCr image which is =
JPEG
compressed and contains a partial strip. The last strip could not be encode=
d
successfully. I found that the failure is occurring in jpeg_write_raw_data =
in
the JPEG library. It seems that the cinfo structure passed to the JPEG libr=
ary
from TIFF library contains incorrect dimensions of the strip if it is parti=
al.</p>

<p class=3D"MsoNormal" style=3D"margin:0in 0in 0.0001pt;font-size:11pt;font=
-family:Calibri,sans-serif">The buffer that is being passed to the library =
is of the
same size as the whole strip (even in the case of a partial strip). In case=
 of
a partial strip, the rest of the buffer is filled with zeros. </p>

<p class=3D"MsoNormal" style=3D"margin:0in 0in 0.0001pt;font-size:11pt;font=
-family:Calibri,sans-serif">=C2=A0</p>

<p class=3D"MsoNormal" style=3D"margin:0in 0in 0.0001pt;font-size:11pt;font=
-family:Calibri,sans-serif">Image details to be written: </p>

<p class=3D"MsoNormal" style=3D"margin:0in 0in 0.0001pt;font-size:11pt;font=
-family:Calibri,sans-serif">&#39;ImageWidth&#39; - 3008</p>

<p class=3D"MsoNormal" style=3D"margin:0in 0in 0.0001pt;font-size:11pt;font=
-family:Calibri,sans-serif">=E2=80=98ImageLength=E2=80=99 - 1952</p>

<p class=3D"MsoNormal" style=3D"margin:0in 0in 0.0001pt;font-size:11pt;font=
-family:Calibri,sans-serif">&#39;Photometric&#39; - YCbCr</p>

<p class=3D"MsoNormal" style=3D"margin:0in 0in 0.0001pt;font-size:11pt;font=
-family:Calibri,sans-serif">&#39;Compression&#39; - JPEG</p>

<p class=3D"MsoNormal" style=3D"margin:0in 0in 0.0001pt;font-size:11pt;font=
-family:Calibri,sans-serif">&#39;BitsPerSample&#39; - 8</p>

<p class=3D"MsoNormal" style=3D"margin:0in 0in 0.0001pt;font-size:11pt;font=
-family:Calibri,sans-serif">&#39;SamplesPerPixel&#39; - 3</p>

<p class=3D"MsoNormal" style=3D"margin:0in 0in 0.0001pt;font-size:11pt;font=
-family:Calibri,sans-serif">=E2=80=98SampleFormat&#39;, - UInt</p>

<p class=3D"MsoNormal" style=3D"margin:0in 0in 0.0001pt;font-size:11pt;font=
-family:Calibri,sans-serif">&#39;PlanarConfiguration&#39; - Chunky</p>

<p class=3D"MsoNormal" style=3D"margin:0in 0in 0.0001pt;font-size:11pt;font=
-family:Calibri,sans-serif">&#39;RowsPerStrip&#39; - 256</p>

<p class=3D"MsoNormal" style=3D"margin:0in 0in 0.0001pt;font-size:11pt;font=
-family:Calibri,sans-serif">&#39;YCbCrSubSampling&#39; - [2 1]</p>

<p class=3D"MsoNormal" style=3D"margin:0in 0in 0.0001pt;font-size:11pt;font=
-family:Calibri,sans-serif">=C2=A0</p>

<p class=3D"MsoNormal" style=3D"margin:0in 0in 0.0001pt;font-size:11pt;font=
-family:Calibri,sans-serif">Can you please confirm if it is a bug?</p><p cl=
ass=3D"MsoNormal" style=3D"margin:0in 0in 0.0001pt;font-size:11pt;font-fami=
ly:Calibri,sans-serif"><br></p><p class=3D"MsoNormal" style=3D"margin:0in 0=
in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">Thanks,</p><p cl=
ass=3D"MsoNormal" style=3D"margin:0in 0in 0.0001pt;font-size:11pt;font-fami=
ly:Calibri,sans-serif">Upanita</p></div>

--00000000000044462005800d64cd--

--===============4666756469027123478==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline

X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KVGlmZiBtYWls
aW5nIGxpc3QKVGlmZkBsaXN0cy5vc2dlby5vcmcKaHR0cHM6Ly9saXN0cy5vc2dlby5vcmcvbWFp
bG1hbi9saXN0aW5mby90aWZmCg==

--===============4666756469027123478==--

