summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Fuzzer/FuzzerLoop.cpp
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2015-07-31 22:07:17 +0000
committerKostya Serebryany <kcc@google.com>2015-07-31 22:07:17 +0000
commit1165efdbf9d5a130a9917b3dd0a0524b400f5719 (patch)
tree1854e1e898b8ca612c6311836ddcdc3211720b91 /llvm/lib/Fuzzer/FuzzerLoop.cpp
parent18edc83b6cee6690dea93b0da82a8ce15a8a006d (diff)
downloadbcm5719-llvm-1165efdbf9d5a130a9917b3dd0a0524b400f5719.tar.gz
bcm5719-llvm-1165efdbf9d5a130a9917b3dd0a0524b400f5719.zip
[libFuzzer] limit the size of the inputs printed to stderr
llvm-svn: 243795
Diffstat (limited to 'llvm/lib/Fuzzer/FuzzerLoop.cpp')
-rw-r--r--llvm/lib/Fuzzer/FuzzerLoop.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerLoop.cpp b/llvm/lib/Fuzzer/FuzzerLoop.cpp
index e659223fe1a..5e8e2e4aae3 100644
--- a/llvm/lib/Fuzzer/FuzzerLoop.cpp
+++ b/llvm/lib/Fuzzer/FuzzerLoop.cpp
@@ -14,6 +14,7 @@
#include <algorithm>
namespace fuzzer {
+static const size_t kMaxUnitSizeToPrint = 4096;
// Only one Fuzzer per process.
static Fuzzer *F;
@@ -68,7 +69,8 @@ void Fuzzer::AlarmCallback() {
Printf("ALARM: working on the last Unit for %zd seconds\n", Seconds);
Printf(" and the timeout value is %d (use -timeout=N to change)\n",
Options.UnitTimeoutSec);
- Print(CurrentUnit, "\n");
+ if (CurrentUnit.size() <= kMaxUnitSizeToPrint)
+ Print(CurrentUnit, "\n");
PrintUnitInASCIIOrTokens(CurrentUnit, "\n");
WriteUnitToFileWithPrefix(CurrentUnit, "timeout-");
exit(1);
@@ -160,7 +162,8 @@ size_t Fuzzer::RunOne(const Unit &U) {
if (TimeOfUnit > TimeOfLongestUnitInSeconds) {
TimeOfLongestUnitInSeconds = TimeOfUnit;
Printf("Longest unit: %zd s:\n", TimeOfLongestUnitInSeconds);
- Print(U, "\n");
+ if (U.size() <= kMaxUnitSizeToPrint)
+ Print(U, "\n");
WriteUnitToFileWithPrefix(U, "long-running-unit-");
}
return Res;
@@ -252,8 +255,11 @@ void Fuzzer::WriteToOutputCorpus(const Unit &U) {
void Fuzzer::WriteUnitToFileWithPrefix(const Unit &U, const char *Prefix) {
std::string Path = Prefix + Hash(U);
WriteToFile(U, Path);
- Printf("Test unit written to %s\nBase64: ", Path.c_str());
- PrintFileAsBase64(Path);
+ Printf("Test unit written to %s\n", Path.c_str());
+ if (U.size() <= kMaxUnitSizeToPrint) {
+ Printf("Base64: ");
+ PrintFileAsBase64(Path);
+ }
}
void Fuzzer::SaveCorpus() {
OpenPOWER on IntegriCloud