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.
  • Loading branch information
kevinbackhouse committed Sep 2, 2021
1 parent 9c4f9c7 commit bd211a9
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 @@ -826,22 +826,20 @@ namespace Exiv2 {
ExifKey key1("Exif.Image.Make");
Value::UniquePtr 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::UniquePtr 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 @@ -979,11 +977,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 bd211a9

Please sign in to comment.