Skip to content

Commit

Permalink
Preven a fault when an option name has an emedded NUL character
Browse files Browse the repository at this point in the history
  • Loading branch information
stephen-webb committed Feb 5, 2025
1 parent 77142ed commit a398cef
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/main/cpp/stringhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,18 @@ using namespace LOG4CXX_NS::helpers;

bool StringHelper::equalsIgnoreCase(const LogString& s1, const logchar* upper, const logchar* lower)
{
for (LogString::const_iterator iter = s1.begin();
iter != s1.end();
iter++, upper++, lower++)
for (auto& item : s1)
{
if (*iter != *upper && *iter != * lower)
if (0 == item || // OSS-Fuzz makes strings with embedded NUL characters
(item != *upper && item != *lower))
{
return false;
}
++upper;
++lower;
}

return (*upper == 0);
return 0 == *upper && iter == s1.end();
}

bool StringHelper::equalsIgnoreCase(const LogString& s1, const LogString& upper, const LogString& lower)
Expand Down

0 comments on commit a398cef

Please sign in to comment.