From f78f2344142baf8159f800f5e8b54d6db0007563 Mon Sep 17 00:00:00 2001 From: Brian Berns Date: Tue, 16 Sep 2025 23:48:08 -0400 Subject: [PATCH] Fixed check for buffer overflow. --- .../Formats/Tiff/Compression/Decompressors/LzwString.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwString.cs b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwString.cs index e6895d67cd..c56b2a6833 100644 --- a/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwString.cs +++ b/src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwString.cs @@ -77,9 +77,9 @@ public class LzwString LzwString e = this; int endIdx = this.Length - 1; - if (endIdx >= buffer.Length) + if (offset + endIdx >= buffer.Length) { - TiffThrowHelper.ThrowImageFormatException("Error reading lzw compressed stream. Either pixel buffer to write to is to small or code length is invalid!"); + TiffThrowHelper.ThrowImageFormatException("Error reading lzw compressed stream. Either pixel buffer to write to is too small or code length is invalid!"); } for (int i = endIdx; i >= 0; i--)