Commit 0dd11393 authored by Amy spark's avatar Amy spark 👉
Browse files

psd: fix reading of layer blending ranges

Freya Lupen's comment regarding a bad check was spot on. Let's add some
hardening while at it, too.

BUG: 459307
(cherry picked from commit bb280906)
parent 4426c4b4
Pipeline #234664 passed with stage
in 47 minutes and 49 seconds
......@@ -350,7 +350,7 @@ bool PSDLayerRecord::readImpl(QIODevice &io)
dbgFile << "\tRead layer mask/adjustment layer data. Length of block:" << layerMaskLength << "pos" << io.pos();
// layer blending thingies
quint32 blendingDataLength;
quint32 blendingDataLength = 0;
if (!psdread<byteOrder>(io, blendingDataLength) || io.bytesAvailable() < blendingDataLength) {
error = "Could not read extra blending data.";
return false;
......@@ -360,26 +360,36 @@ bool PSDLayerRecord::readImpl(QIODevice &io)
dbgFile << "\tNumber of blending channels:" << blendingNchannels;
if (blendingNchannels > 0) {
if (!psdread<byteOrder>(io, blendingRanges.compositeGrayRange.first.blackValues[0])
|| !psdread<byteOrder>(io, blendingRanges.compositeGrayRange.first.blackValues[1])
|| !psdread<byteOrder>(io, blendingRanges.compositeGrayRange.first.whiteValues[0])
|| !psdread<byteOrder>(io, blendingRanges.compositeGrayRange.first.whiteValues[1])
|| !psdread<byteOrder>(io, blendingRanges.compositeGrayRange.second.blackValues[0])
|| !psdread<byteOrder>(io, blendingRanges.compositeGrayRange.second.blackValues[1])
|| !psdread<byteOrder>(io, blendingRanges.compositeGrayRange.second.whiteValues[0])
|| !psdread<byteOrder>(io, blendingRanges.compositeGrayRange.second.whiteValues[1])) {
error = "Could not read blending black/white values";
return false;
if (blendingDataLength > 0) {
if (blendingDataLength > 0) {
if (!psdread<byteOrder>(io, blendingRanges.compositeGrayRange.first.blackValues[0])
|| !psdread<byteOrder>(io, blendingRanges.compositeGrayRange.first.blackValues[1])
|| !psdread<byteOrder>(io, blendingRanges.compositeGrayRange.first.whiteValues[0])
|| !psdread<byteOrder>(io, blendingRanges.compositeGrayRange.first.whiteValues[1])) {
error = "Could not read blending black/white values";
return false;
}
}
blendingDataLength -= 4;
if (blendingDataLength > 0) {
if (!psdread<byteOrder>(io, blendingRanges.compositeGrayRange.second.blackValues[0])
|| !psdread<byteOrder>(io, blendingRanges.compositeGrayRange.second.blackValues[1])
|| !psdread<byteOrder>(io, blendingRanges.compositeGrayRange.second.whiteValues[0])
|| !psdread<byteOrder>(io, blendingRanges.compositeGrayRange.second.whiteValues[1])) {
error = "Could not read blending black/white values";
return false;
}
}
blendingDataLength -= 4;
dbgFile << "\tBlending ranges:";
dbgFile << "\t\tcomposite gray (source) :" << blendingRanges.compositeGrayRange.first;
dbgFile << "\t\tcomposite gray (dest):" << blendingRanges.compositeGrayRange.second;
for (quint32 i = 0; i < blendingNchannels; ++i) {
LayerBlendingRanges::LayerBlendingRange src;
LayerBlendingRanges::LayerBlendingRange dst;
LayerBlendingRanges::LayerBlendingRange src{};
LayerBlendingRanges::LayerBlendingRange dst{};
if (!psdread<byteOrder>(io, src.blackValues[0]) || !psdread<byteOrder>(io, src.blackValues[1]) || !psdread<byteOrder>(io, src.whiteValues[0])
|| !psdread<byteOrder>(io, src.whiteValues[1]) || !psdread<byteOrder>(io, dst.blackValues[0]) || !psdread<byteOrder>(io, dst.blackValues[1])
|| !psdread<byteOrder>(io, dst.whiteValues[0]) || !psdread<byteOrder>(io, dst.whiteValues[1])) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment