This is an automated email from the ASF dual-hosted git repository.

swebb2066 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git


The following commit(s) were added to refs/heads/master by this push:
     new 32c131c8 Prevent a fault when an option name has an emedded NUL 
character (#477)
32c131c8 is described below

commit 32c131c8e4638e9309847c7994391ea527cfa536
Author: Stephen Webb <[email protected]>
AuthorDate: Wed Feb 5 15:30:11 2025 +1100

    Prevent a fault when an option name has an emedded NUL character (#477)
---
 src/main/cpp/stringhelper.cpp | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/main/cpp/stringhelper.cpp b/src/main/cpp/stringhelper.cpp
index 7519c03e..17321e03 100644
--- a/src/main/cpp/stringhelper.cpp
+++ b/src/main/cpp/stringhelper.cpp
@@ -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 (const 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;
 }
 
 bool StringHelper::equalsIgnoreCase(const LogString& s1, const LogString& 
upper, const LogString& lower)

Reply via email to