fix(codecs): read TIFF strips larger than the 64 MB per-read cap
Single-strip uncompressed files (Photoshop's default) exceed TiffReader's bounded read; such strips are now read in pieces, the uncompressed path skips a copy, and hostile strip/tile counts are rejected up front. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
2 files changed
+38
-4
No files matched your search
@@ -127,6 +127,20 @@ public sealed class TiffTests(TestContext context)
|
||||
Assert.SequenceEqual(samples, Raster(tiff).Samples!);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SingleStripLargerThanTheReaderCapDecodes()
|
||||
{
|
||||
// Photoshop-style single uncompressed strip of 70 MB (TiffReader reads at most 64 MB per call).
|
||||
const int w = 5000, h = 7000;
|
||||
var strip = new byte[w * h * 2];
|
||||
for (var i = 0; i < strip.Length; i += 2) BinaryPrimitives.WriteUInt16LittleEndian(strip.AsSpan(i), (ushort)(i * 7));
|
||||
var tiff = TiffTestEncoders.Build(d => Layout(d, w, h, 1, 16, compression: 1), [strip], tiled: false);
|
||||
var raster = Raster(tiff);
|
||||
Assert.Empty(raster.Warnings);
|
||||
Assert.Equal(unchecked((ushort)((w * h - 1) * 2 * 7)), raster.Samples![^1]);
|
||||
Assert.Equal(unchecked((ushort)(12345 * 2 * 7)), raster.Samples[12345]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PackedTwelveBitSamplesUnpack()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user