You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by sw...@apache.org on 2026/09/01 01:51:41 UTC
(logging-log4cxx) branch upgrade_fuzzing created (now c8e6accc)
This is an automated email from the ASF dual-hosted git repository.
swebb2066 pushed a change to branch upgrade_fuzzing
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
at c8e6accc Simplify PatternLayoutFuzzer
This branch includes the following new commits:
new c8e6accc Simplify PatternLayoutFuzzer
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(logging-log4cxx) 01/01: Simplify PatternLayoutFuzzer
Posted by sw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
swebb2066 pushed a commit to branch upgrade_fuzzing
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
commit c8e6acccade469053124ba7adfbf627c7d186eb9
Author: Stephen Webb <sw...@gmail.com>
AuthorDate: Tue Sep 1 11:51:19 2026 +1000
Simplify PatternLayoutFuzzer
---
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;
}