#764: Applied patch.

v0.27.3
Andreas Huggel 14 years ago
parent c73268a27c
commit a08a33faf5

@ -400,7 +400,7 @@ namespace Exiv2 {
uint32_t resourceType = getULong(buf, bigEndian); uint32_t resourceType = getULong(buf, bigEndian);
if (resourceType != kPhotoshopResourceType) { if (resourceType != kPhotoshopResourceType) {
break; // bad resource type throw Error(3, "Photoshop"); // bad resource type
} }
uint16_t resourceId = getUShort(buf + 4, bigEndian); uint16_t resourceId = getUShort(buf + 4, bigEndian);
uint32_t resourceNameLength = buf[6]; uint32_t resourceNameLength = buf[6];
@ -416,13 +416,13 @@ namespace Exiv2 {
if (io_->read(buf, 4) != 4) throw Error(3, "Photoshop"); if (io_->read(buf, 4) != 4) throw Error(3, "Photoshop");
uint32_t resourceSize = getULong(buf, bigEndian); uint32_t resourceSize = getULong(buf, bigEndian);
uint32_t pResourceSize = (resourceSize + 1) & ~1; // padded resource size
uint32_t curOffset = io_->tell(); uint32_t curOffset = io_->tell();
// Write IPTC_NAA resource block // Write IPTC_NAA resource block
if ((resourceId == kPhotoshopResourceID_IPTC_NAA || if ((resourceId == kPhotoshopResourceID_IPTC_NAA ||
resourceId > kPhotoshopResourceID_IPTC_NAA) && iptcDone == false) { resourceId > kPhotoshopResourceID_IPTC_NAA) && iptcDone == false) {
newResLength += writeIptcData(iptcData_, outIo); newResLength += writeIptcData(iptcData_, outIo);
resourceSize = (resourceSize + 1) & ~1; // adjust for padding
iptcDone = true; iptcDone = true;
} }
@ -430,7 +430,6 @@ namespace Exiv2 {
else if ((resourceId == kPhotoshopResourceID_ExifInfo || else if ((resourceId == kPhotoshopResourceID_ExifInfo ||
resourceId > kPhotoshopResourceID_ExifInfo) && exifDone == false) { resourceId > kPhotoshopResourceID_ExifInfo) && exifDone == false) {
newResLength += writeExifData(exifData_, outIo); newResLength += writeExifData(exifData_, outIo);
resourceSize = (resourceSize + 1) & ~1; // adjust for padding
exifDone = true; exifDone = true;
} }
@ -438,7 +437,6 @@ namespace Exiv2 {
else if ((resourceId == kPhotoshopResourceID_XMPPacket || else if ((resourceId == kPhotoshopResourceID_XMPPacket ||
resourceId > kPhotoshopResourceID_XMPPacket) && xmpDone == false) { resourceId > kPhotoshopResourceID_XMPPacket) && xmpDone == false) {
newResLength += writeXmpData(xmpData_, outIo); newResLength += writeXmpData(xmpData_, outIo);
resourceSize = (resourceSize + 1) & ~1; // adjust for padding
xmpDone = true; xmpDone = true;
} }
@ -467,10 +465,9 @@ namespace Exiv2 {
readTotal = 0; readTotal = 0;
toRead = 0; toRead = 0;
resourceSize = (resourceSize + 1) & ~1; // pad to even while (readTotal < pResourceSize) {
while (readTotal < resourceSize) { toRead = static_cast<long>(pResourceSize - readTotal) < lbuf.size_
toRead = static_cast<long>(resourceSize - readTotal) < lbuf.size_ ? static_cast<long>(pResourceSize - readTotal) : lbuf.size_;
? static_cast<long>(resourceSize - readTotal) : lbuf.size_;
if (io_->read(lbuf.pData_, toRead) != toRead) { if (io_->read(lbuf.pData_, toRead) != toRead) {
throw Error(3, "Photoshop"); throw Error(3, "Photoshop");
} }
@ -478,11 +475,11 @@ namespace Exiv2 {
if (outIo.write(lbuf.pData_, toRead) != toRead) throw Error(21); if (outIo.write(lbuf.pData_, toRead) != toRead) throw Error(21);
} }
if (outIo.error()) throw Error(21); if (outIo.error()) throw Error(21);
newResLength += resourceSize + adjResourceNameLen + 12; newResLength += pResourceSize + adjResourceNameLen + 12;
} }
io_->seek(curOffset + resourceSize, BasicIo::beg); io_->seek(curOffset + pResourceSize, BasicIo::beg);
oldResLength -= (12 + adjResourceNameLen + resourceSize); oldResLength -= (12 + adjResourceNameLen + pResourceSize);
} }
// Append IPTC_NAA resource block, if not yet written // Append IPTC_NAA resource block, if not yet written

Loading…
Cancel
Save