From 6be9b6349d617315600d2d5bda63d896d133e8d1 Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Tue, 1 Dec 2020 22:22:20 +0100 Subject: [PATCH] LibGfx: Prevent potential heap-overflow in BMP non-RLE --- Libraries/LibGfx/BMPLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/LibGfx/BMPLoader.cpp b/Libraries/LibGfx/BMPLoader.cpp index 2e37c840a6..72bad19642 100644 --- a/Libraries/LibGfx/BMPLoader.cpp +++ b/Libraries/LibGfx/BMPLoader.cpp @@ -1200,7 +1200,7 @@ static bool decode_bmp_pixel_data(BMPLoadingContext& context) return false; } - auto buffer = ByteBuffer::wrap(const_cast(context.file_bytes + context.data_offset), context.file_size); + auto buffer = ByteBuffer::wrap(const_cast(context.file_bytes + context.data_offset), context.file_size - context.data_offset); if (context.dib.info.compression == Compression::RLE4 || context.dib.info.compression == Compression::RLE8 || context.dib.info.compression == Compression::RLE24) {