File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -288,14 +288,18 @@ namespace Exiv2 {
288288 // Write existing stuff after record,
289289 // skip the current and all remaining IPTC blocks
290290 long pos = sizeFront;
291- while (0 == Photoshop::locateIptcIrb (pPsData + pos, sizePsData - pos,
291+ long nextSizeData = Safe::add<long >(sizePsData, -pos);
292+ enforce (nextSizeData >= 0 , kerCorruptedMetadata);
293+ while (0 == Photoshop::locateIptcIrb (pPsData + pos, nextSizeData,
292294 &record, &sizeHdr, &sizeIptc)) {
293295 const long newPos = static_cast <long >(record - pPsData);
294296 // Copy data up to the IPTC IRB
295297 if (newPos > pos) {
296298 append (psBlob, pPsData + pos, newPos - pos);
297299 }
298300 // Skip the IPTC IRB
301+ nextSizeData = Safe::add<long >(sizePsData, -pos);
302+ enforce (nextSizeData >= 0 , kerCorruptedMetadata);
299303 pos = newPos + sizeHdr + sizeIptc + (sizeIptc & 1 );
300304 }
301305 if (pos < sizePsData) {
You can’t perform that action at this time.
0 commit comments