psd: Fix crash on broken files

Instead of resizing the bytearray to the potential size and then reading
into it, ask the device to read into a bytearray, this way instead of a
crash because we're trying to resize to a too big number we get a nice
  maxSize argument exceeds QByteArray size limit
warning

oss-fuzz/46664
This commit is contained in:
Albert Astals Cid 2022-04-13 23:06:15 +02:00
parent 44fd6b7bc0
commit 343954ca98

View File

@ -271,9 +271,8 @@ PSDColorModeDataSection readColorModeDataSection(QDataStream &s, bool *ok = null
// Official Adobe specification tells "Only indexed color and duotone
// (see the mode field in the File header section) have color mode data.".
// See test case images 32bit_grayscale.psd and 32bit-rgb.psd
auto&& ba = cms.duotone.data;
ba.resize(size);
if (s.readRawData(ba.data(), ba.size()) != ba.size())
cms.duotone.data = s.device()->read(size);
if (cms.duotone.data.size() != size)
*ok = false;
}
else { // read the palette (768 bytes)