From 0710bc65f64b12d0536fedb8c5fff89b4009c439 Mon Sep 17 00:00:00 2001 From: Mirco Miranda Date: Thu, 29 Feb 2024 15:55:57 +0100 Subject: [PATCH] More header checks (CCBUG: 479612) --- src/imageformats/tga.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/imageformats/tga.cpp b/src/imageformats/tga.cpp index 59f6efd..732392e 100644 --- a/src/imageformats/tga.cpp +++ b/src/imageformats/tga.cpp @@ -117,6 +117,10 @@ static bool IsSupported(const TgaHeader &head) if (head.pixel_size != 8 && head.pixel_size != 16 && head.pixel_size != 24 && head.pixel_size != 32) { return false; } + // If the colormap_type field is set to zero, indicating that no color map exists, then colormap_size, colormap_index and colormap_length should be set to zero. + if (head.colormap_type == 0 && (head.colormap_size != 0 || head.colormap_index != 0 || head.colormap_length != 0)) { + return false; + } return true; }