Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…l?id=37889

Avoid reading 1 byte off the end when the string does not contain a '\0' byte.

(cherry picked from commit bd211a9)
  • Loading branch information
kevinbackhouse authored and mergify-bot committed Sep 2, 2021
1 parent bc480dc commit a95fe1f
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/crwimage_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -847,22 +847,20 @@ namespace Exiv2 {
ExifKey key1("Exif.Image.Make");
Value::AutoPtr value1 = Value::create(ciffComponent.typeId());
uint32_t i = 0;
for (; i < ciffComponent.size()
&& ciffComponent.pData()[i] != '\0'; ++i) {
while (i < ciffComponent.size() && ciffComponent.pData()[i++] != '\0') {
// empty
}
value1->read(ciffComponent.pData(), ++i, byteOrder);
value1->read(ciffComponent.pData(), i, byteOrder);
image.exifData().add(key1, value1.get());

// Model
ExifKey key2("Exif.Image.Model");
Value::AutoPtr value2 = Value::create(ciffComponent.typeId());
uint32_t j = i;
for (; i < ciffComponent.size()
&& ciffComponent.pData()[i] != '\0'; ++i) {
while (i < ciffComponent.size() && ciffComponent.pData()[i++] != '\0') {
// empty
}
value2->read(ciffComponent.pData() + j, i - j + 1, byteOrder);
value2->read(ciffComponent.pData() + j, i - j, byteOrder);
image.exifData().add(key2, value2.get());
} // CrwMap::decode0x080a

Expand Down Expand Up @@ -1000,11 +998,10 @@ namespace Exiv2 {
else if (ciffComponent.typeId() == asciiString) {
// determine size from the data, by looking for the first 0
uint32_t i = 0;
for (; i < ciffComponent.size()
&& ciffComponent.pData()[i] != '\0'; ++i) {
while (i < ciffComponent.size() && ciffComponent.pData()[i++] != '\0') {
// empty
}
size = ++i;
size = i;
}
else {
// by default, use the size from the directory entry
Expand Down

0 comments on commit a95fe1f

Please sign in to comment.