Skip to content

Commit f78f234

Browse files
committed
Fixed check for buffer overflow.
1 parent 3948fa8 commit f78f234

File tree

1 file changed

+2
-2
lines changed
  • src/ImageSharp/Formats/Tiff/Compression/Decompressors

1 file changed

+2
-2
lines changed

src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwString.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ public int WriteTo(Span<byte> buffer, int offset)
7777

7878
LzwString e = this;
7979
int endIdx = this.Length - 1;
80-
if (endIdx >= buffer.Length)
80+
if (offset + endIdx >= buffer.Length)
8181
{
82-
TiffThrowHelper.ThrowImageFormatException("Error reading lzw compressed stream. Either pixel buffer to write to is to small or code length is invalid!");
82+
TiffThrowHelper.ThrowImageFormatException("Error reading lzw compressed stream. Either pixel buffer to write to is too small or code length is invalid!");
8383
}
8484

8585
for (int i = endIdx; i >= 0; i--)

0 commit comments

Comments
 (0)