Skip to content

Commit 457436d

Browse files
committed
Add test case for not enough data reading InternationalText chunk
1 parent fca50b9 commit 457436d

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.Chunks.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,29 @@ public void Decode_CompressedTxtChunk_WithTruncatedData_DoesNotThrow()
115115
using Image<Rgba32> image = Image.Load<Rgba32>(stream);
116116
}
117117

118+
// https://github.com/SixLabors/ImageSharp/issues/3079
119+
[Fact]
120+
public void Decode_InternationalText_WithTruncatedData_DoesNotThrow()
121+
{
122+
byte[] payload = [137, 80, 78, 71, 13, 10, 26, 10, // PNG signature
123+
0, 0, 0, 13, // chunk length 13 bytes
124+
73, 72, 68, 82, // chunk type IHDR
125+
0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, // data
126+
55, 110, 249, 36, // checksum
127+
0, 0, 0, 2, // chunk length
128+
105, 84, 88, 116, // chunk type iTXt
129+
1, 0, // truncated data
130+
225, 200, 214, 33, // crc
131+
0, 0, 0, 10, // chunk length 10 bytes
132+
73, 68, 65, 84, // chunk type IDAT
133+
120, 1, 99, 96, 0, 0, 0, 2, 0, 1, // data
134+
115, 117, 1, 24, // checksum
135+
0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130]; // end chunk
136+
137+
using MemoryStream stream = new(payload);
138+
using Image<Rgba32> image = Image.Load<Rgba32>(stream);
139+
}
140+
118141
private static string GetChunkTypeName(uint value)
119142
{
120143
byte[] data = new byte[4];

0 commit comments

Comments
 (0)