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 0eac25df Prevent timeout fault running JSONLayoutFuzzer (#478)
0eac25df is described below
commit 0eac25dff2cf2a1737b72c4c8e65cd913b495f80
Author: Stephen Webb <[email protected]>
AuthorDate: Fri Feb 7 11:52:13 2025 +1100
Prevent timeout fault running JSONLayoutFuzzer (#478)
---
src/fuzzers/cpp/JSONLayoutFuzzer.cpp | 29 ++++++++++++++++++-----------
1 file changed, 18 insertions(+), 11 deletions(-)
diff --git a/src/fuzzers/cpp/JSONLayoutFuzzer.cpp
b/src/fuzzers/cpp/JSONLayoutFuzzer.cpp
index 45529323..e6c1faf3 100644
--- a/src/fuzzers/cpp/JSONLayoutFuzzer.cpp
+++ b/src/fuzzers/cpp/JSONLayoutFuzzer.cpp
@@ -24,6 +24,13 @@
#include <log4cxx/jsonlayout.h>
#include <log4cxx/helpers/transcoder.h>
+namespace
+{
+ const int MaxKeyLength = 50;
+ const int MaxValueLength = 500;
+ const int MaxMessageLength = 2000;
+}
+
using namespace log4cxx;
using namespace log4cxx::helpers;
using namespace log4cxx::spi;
@@ -48,17 +55,17 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data,
size_t size) {
}
// Create random strings we need later
- std::string key1Str = fdp.ConsumeRandomLengthString();
- std::string val1Str = fdp.ConsumeRandomLengthString();
- std::string key2Str = fdp.ConsumeRandomLengthString();
- std::string val2Str = fdp.ConsumeRandomLengthString();
- std::string key3Str = fdp.ConsumeRandomLengthString();
- std::string val3Str = fdp.ConsumeRandomLengthString();
- std::string key4Str = fdp.ConsumeRandomLengthString();
- std::string val4Str = fdp.ConsumeRandomLengthString();
- std::string ndcMessageStr = fdp.ConsumeRandomLengthString();
- std::string loggerStr = fdp.ConsumeRandomLengthString();
- std::string contentStr = fdp.ConsumeRemainingBytesAsString();
+ std::string key1Str = fdp.ConsumeRandomLengthString(MaxKeyLength);
+ std::string val1Str = fdp.ConsumeRandomLengthString(MaxValueLength);
+ std::string key2Str = fdp.ConsumeRandomLengthString(MaxKeyLength);
+ std::string val2Str = fdp.ConsumeRandomLengthString(MaxValueLength);
+ std::string key3Str = fdp.ConsumeRandomLengthString(MaxKeyLength);
+ std::string val3Str = fdp.ConsumeRandomLengthString(MaxValueLength);
+ std::string key4Str = fdp.ConsumeRandomLengthString(MaxKeyLength);
+ std::string val4Str = fdp.ConsumeRandomLengthString(MaxValueLength);
+ std::string ndcMessageStr =
fdp.ConsumeRandomLengthString(MaxMessageLength);
+ std::string loggerStr = fdp.ConsumeRandomLengthString(MaxKeyLength);
+ std::string contentStr =
fdp.ConsumeRandomLengthString(MaxMessageLength);
LogString key1, val1, key2, val2, key3, val3, key4, val4, ndcMessage,
logger, content;
Transcoder::decode(key1Str, key1);