mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2025-06-03 00:58:15 -04:00
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:
parent
44fd6b7bc0
commit
343954ca98
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user