From 4bf2894bdee81ae7da6953f05915351685373b75 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Thu, 5 Sep 2019 20:05:29 +0200 Subject: [PATCH] Fix uninitialized memory read Summary: Make sure whole of pixel_size in pixel has data either because it was read or because we set it to 0 oss-fuzz/14565 Reviewers: dfaure, apol, vkrause Reviewed By: vkrause Subscribers: kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D23739 --- src/imageformats/tga.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/imageformats/tga.cpp b/src/imageformats/tga.cpp index 46129bb..6b0b600 100644 --- a/src/imageformats/tga.cpp +++ b/src/imageformats/tga.cpp @@ -252,7 +252,10 @@ static bool LoadTGA(QDataStream &s, const TgaHeader &tga, QImage &img) // RLE pixels. assert(pixel_size <= 8); char pixel[8]; - s.readRawData(pixel, pixel_size); + const int dataRead = s.readRawData(pixel, pixel_size); + if (dataRead < (int)pixel_size) { + memset(&pixel[dataRead], 0, pixel_size - dataRead); + } do { memcpy(dst, pixel, pixel_size); dst += pixel_size;