Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove strnlen usage
Browse files Browse the repository at this point in the history
It causes issues with Cygwin's libc. Needs _GNU_SOURCE

Signed-off-by: Rosen Penev <rosenp@gmail.com>
neheb committed Jan 12, 2025
1 parent 275cb13 commit 8f4a329
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/bmffimage.cpp
Original file line number Diff line number Diff line change
@@ -363,8 +363,8 @@ uint64_t BmffImage::boxHandler(std::ostream& out /* = std::cout*/, Exiv2::PrintS
// Check that the string has a '\0' terminator.
const char* str = data.c_str(skip);
const size_t maxlen = data.size() - skip;
Internal::enforce(maxlen > 0 && strnlen(str, maxlen) < maxlen, Exiv2::ErrorCode::kerCorruptedMetadata);
std::string name(str);
Internal::enforce(maxlen > 0 && name.size() < maxlen, Exiv2::ErrorCode::kerCorruptedMetadata);
if (Internal::contains(name, "Exif")) { // "Exif" or "ExifExif"
exifID_ = ID;
id = " *** Exif ***";
5 changes: 4 additions & 1 deletion src/helper_functions.cpp
Original file line number Diff line number Diff line change
@@ -13,7 +13,10 @@ std::string string_from_unterminated(const char* data, size_t data_length) {
if (data_length == 0) {
return {};
}
const size_t StringLength = strnlen(data, data_length);
size_t StringLength = 0;
while (StringLength < data_length && data[StringLength] != '\0') {
StringLength++;
}
return {data, StringLength};
}

0 comments on commit 8f4a329

Please sign in to comment.