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 c42ffebe Simplify PatternLayoutFuzzer (#751)
c42ffebe is described below
commit c42ffebe7a267639a6526a80ecc27f7493e5b9c0
Author: Stephen Webb <[email protected]>
AuthorDate: Wed Sep 2 14:20:45 2026 +1000
Simplify PatternLayoutFuzzer (#751)
---
src/fuzzers/cpp/PatternLayoutFuzzer.cpp | 34 ++++-----------------------------
1 file changed, 4 insertions(+), 30 deletions(-)
diff --git a/src/fuzzers/cpp/PatternLayoutFuzzer.cpp
b/src/fuzzers/cpp/PatternLayoutFuzzer.cpp
index d0e6db31..ad4d1d6d 100644
--- a/src/fuzzers/cpp/PatternLayoutFuzzer.cpp
+++ b/src/fuzzers/cpp/PatternLayoutFuzzer.cpp
@@ -16,10 +16,6 @@
*/
#include <iostream> // for `cout`, `endl`
-#include <cstdlib> // for `exit()`, `EXIT_FAILURE`
-#include <unistd.h> // for `readlink`, `chdir`
-#include <libgen.h> // for `dirname`
-#include <limits.h> // for `PATH_MAX`
#include <iomanip> // for `put_time()`
#include <ctime> // for `time()`
#include <fuzzer/FuzzedDataProvider.h>
@@ -53,9 +49,9 @@ public:
return true;
}
- void append(const spi::LoggingEventPtr& event, helpers::Pool& pool)
override {
+ void append( LOG4CXX_APPEND_FORMAL_PARAMETERS ) override {
LogString msg;
- getLayout()->format(msg, event, pool);
+ getLayout()->format(msg, event);
}
void setOption(const LogString& option, const LogString& value)
override {}
@@ -64,8 +60,6 @@ public:
IMPLEMENT_LOG4CXX_OBJECT(EncodingAppender)
-LOG4CXX_PTR_DEF(EncodingAppender);
-
} // namespace
static std::time_t logTime;
@@ -75,26 +69,6 @@ static std::tm* logTimeBuffer;
logTimeBuffer = std::localtime(&logTime); \
stream << std::put_time(logTimeBuffer, "%Y-%m-%d %H:%M:%S") << " [" <<
__FILE_NAME__ << ":" << __LINE__ << "] "
-static void findExecutablePath(char* buffer) {
- ssize_t length = readlink("/proc/self/exe", buffer, PATH_MAX);
- if (length == -1) {
- LOG(std::cerr) << "ERROR: Failed to find the executable path" <<
std::endl;
- exit(EXIT_FAILURE);
- }
- buffer[length] = '\0';
-}
-
-static void chdirExecutableHome() {
- char executablePath[PATH_MAX];
- findExecutablePath(executablePath);
- char* executableHome = dirname(executablePath);
- if (chdir(executableHome) != 0) {
- LOG(std::cerr) << "DEBUG: Executable path: " << executablePath
<< std::endl;
- LOG(std::cerr) << "DEBUG: Executable home: " << executableHome
<< std::endl;
- LOG(std::cerr) << "ERROR: Failed to `chdir()` the executable
path" << std::endl;
- }
-}
-
static int INITIALIZED = 0;
static void init() {
@@ -102,8 +76,8 @@ static void init() {
return;
}
LOG(std::cout) << "INFO: Produced using the Git commit ID: " <<
GIT_COMMIT_ID << std::endl;
- chdirExecutableHome();
- PropertyConfigurator::configure("PatternLayoutFuzzer.properties");
+ auto programFilePath =
spi::Configurator::properties().getProperty(LOG4CXX_STR("PROGRAM_FILE_PATH.PARENT_PATH"));
+ PropertyConfigurator::configure(programFilePath +
LOG4CXX_STR("/PatternLayoutFuzzer.properties"));
INITIALIZED = 1;
}