-
Notifications
You must be signed in to change notification settings - Fork 278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix issue #306 #316
Fix issue #306 #316
Changes from 1 commit
88ec00b
bf79396
4bab67e
758a814
838dee7
4fbfdbb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,22 +165,28 @@ namespace Exiv2 { | |
else if(type == iTXt_Chunk) | ||
{ | ||
const int nullSeparators = std::count(&data.pData_[keysize+3], &data.pData_[data.size_-1], '\0'); | ||
enforce(nullSeparators >= 2, Exiv2::kerCorruptedMetadata); | ||
enforce(nullSeparators >= 2, Exiv2::kerCorruptedMetadata, "iTXt chunk: not enough null separators"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The message you added will not be displayed, as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I noticed that the message was not printed, but I thought it could be a good idea to have that string there in case we can add unit tests in the future around this code. I did not check though if we could get the string when catching the exception in the unit tests code. Anyways, I think it does not hurt to have a small string in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It will hurt the performance slightly in case the exception gets thrown, as then the |
||
|
||
// Extract a deflate compressed or uncompressed UTF-8 text chunk | ||
|
||
// we get the compression flag after the key | ||
const byte* compressionFlag = data.pData_ + keysize + 1; | ||
const byte compressionFlag = data.pData_[keysize + 1]; | ||
// we get the compression method after the compression flag | ||
const byte* compressionMethod = data.pData_ + keysize + 2; | ||
const byte compressionMethod = data.pData_[keysize + 2]; | ||
|
||
enforce(compressionFlag == 0x00 || compressionFlag == 0x01, Exiv2::kerCorruptedMetadata, | ||
"iTXt chunk: not valid value in compressionFlag"); | ||
enforce(compressionMethod == 0x00, Exiv2::kerCorruptedMetadata, | ||
"iTXt chunk: not valid value in compressionMethod"); | ||
|
||
// language description string after the compression technique spec | ||
std::string languageText((const char*)(data.pData_ + keysize + 3)); | ||
unsigned int languageTextSize = static_cast<unsigned int>(languageText.size()); | ||
// translated keyword string after the language description | ||
std::string translatedKeyText((const char*)(data.pData_ + keysize + 3 + languageTextSize +1)); | ||
unsigned int translatedKeyTextSize = static_cast<unsigned int>(translatedKeyText.size()); | ||
|
||
if ( compressionFlag[0] == 0x00 ) | ||
if ( compressionFlag == 0x00 ) | ||
{ | ||
// then it's an uncompressed iTXt chunk | ||
#ifdef DEBUG | ||
|
@@ -194,7 +200,7 @@ namespace Exiv2 { | |
arr.alloc(textsize); | ||
arr = DataBuf(text, textsize); | ||
} | ||
else if ( compressionFlag[0] == 0x01 && compressionMethod[0] == 0x00 ) | ||
else if ( compressionFlag == 0x01 && compressionMethod == 0x00 ) | ||
{ | ||
// then it's a zlib compressed iTXt chunk | ||
#ifdef DEBUG | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh, I think this should be
&data.pData_[data.size_]
as the end iterator should point to the first element outside of the range.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahg, you are right. I'll create a mini PR fixing that.