From 18e17d3a7a6f2b2835638b1e963b7adb458a309b Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Tue, 29 Jan 2019 12:39:52 +0100 Subject: [PATCH] tga: Don't support more than 8 alpha bits Fixes undefined left shift with negative values oss-fuzz/12764 --- src/imageformats/tga.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/imageformats/tga.cpp b/src/imageformats/tga.cpp index 9217bed..2ca9d1d 100644 --- a/src/imageformats/tga.cpp +++ b/src/imageformats/tga.cpp @@ -186,6 +186,10 @@ static bool LoadTGA(QDataStream &s, const TgaHeader &tga, QImage &img) // However alpha exists only in the 32 bit format. if ((tga.pixel_size == 32) && (tga.flags & 0xf)) { img = QImage(tga.width, tga.height, QImage::Format_ARGB32); + + if (numAlphaBits > 8) { + return false; + } } uint pixel_size = (tga.pixel_size / 8);