Skip to content

Commit

Permalink
Merge pull request #2194 from Exiv2/027_fix2179
Browse files Browse the repository at this point in the history
[027] Fix integer overflow #2179
  • Loading branch information
piponazo authored Apr 6, 2022
2 parents 3409ddd + e54f5c9 commit 036af47
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/jpgimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,18 @@ namespace Exiv2 {
// Write existing stuff after record,
// skip the current and all remaining IPTC blocks
long pos = sizeFront;
while (0 == Photoshop::locateIptcIrb(pPsData + pos, sizePsData - pos,
long nextSizeData = Safe::add<long>(sizePsData, -pos);
enforce(nextSizeData >= 0, kerCorruptedMetadata);
while (0 == Photoshop::locateIptcIrb(pPsData + pos, nextSizeData,
&record, &sizeHdr, &sizeIptc)) {
const long newPos = static_cast<long>(record - pPsData);
// Copy data up to the IPTC IRB
if (newPos > pos) {
append(psBlob, pPsData + pos, newPos - pos);
}
// Skip the IPTC IRB
nextSizeData = Safe::add<long>(sizePsData, -pos);
enforce(nextSizeData >= 0, kerCorruptedMetadata);
pos = newPos + sizeHdr + sizeIptc + (sizeIptc & 1);
}
if (pos < sizePsData) {
Expand Down

0 comments on commit 036af47

Please sign in to comment.