mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-27 04:18:42 +00:00
[libFuzzer] limit the size of the inputs printed to stderr
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243795 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
1 parent
cab56781b5
commit
427b5a50cf
1 file changed
+10
-4
@@ -14,6 +14,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
namespace fuzzer {
|
namespace fuzzer {
|
||||||
|
static const size_t kMaxUnitSizeToPrint = 4096;
|
||||||
|
|
||||||
// Only one Fuzzer per process.
|
// Only one Fuzzer per process.
|
||||||
static Fuzzer *F;
|
static Fuzzer *F;
|
||||||
@@ -68,7 +69,8 @@ void Fuzzer::AlarmCallback() {
|
|||||||
Printf("ALARM: working on the last Unit for %zd seconds\n", Seconds);
|
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",
|
Printf(" and the timeout value is %d (use -timeout=N to change)\n",
|
||||||
Options.UnitTimeoutSec);
|
Options.UnitTimeoutSec);
|
||||||
Print(CurrentUnit, "\n");
|
if (CurrentUnit.size() <= kMaxUnitSizeToPrint)
|
||||||
|
Print(CurrentUnit, "\n");
|
||||||
PrintUnitInASCIIOrTokens(CurrentUnit, "\n");
|
PrintUnitInASCIIOrTokens(CurrentUnit, "\n");
|
||||||
WriteUnitToFileWithPrefix(CurrentUnit, "timeout-");
|
WriteUnitToFileWithPrefix(CurrentUnit, "timeout-");
|
||||||
exit(1);
|
exit(1);
|
||||||
@@ -160,7 +162,8 @@ size_t Fuzzer::RunOne(const Unit &U) {
|
|||||||
if (TimeOfUnit > TimeOfLongestUnitInSeconds) {
|
if (TimeOfUnit > TimeOfLongestUnitInSeconds) {
|
||||||
TimeOfLongestUnitInSeconds = TimeOfUnit;
|
TimeOfLongestUnitInSeconds = TimeOfUnit;
|
||||||
Printf("Longest unit: %zd s:\n", TimeOfLongestUnitInSeconds);
|
Printf("Longest unit: %zd s:\n", TimeOfLongestUnitInSeconds);
|
||||||
Print(U, "\n");
|
if (U.size() <= kMaxUnitSizeToPrint)
|
||||||
|
Print(U, "\n");
|
||||||
WriteUnitToFileWithPrefix(U, "long-running-unit-");
|
WriteUnitToFileWithPrefix(U, "long-running-unit-");
|
||||||
}
|
}
|
||||||
return Res;
|
return Res;
|
||||||
@@ -252,8 +255,11 @@ void Fuzzer::WriteToOutputCorpus(const Unit &U) {
|
|||||||
void Fuzzer::WriteUnitToFileWithPrefix(const Unit &U, const char *Prefix) {
|
void Fuzzer::WriteUnitToFileWithPrefix(const Unit &U, const char *Prefix) {
|
||||||
std::string Path = Prefix + Hash(U);
|
std::string Path = Prefix + Hash(U);
|
||||||
WriteToFile(U, Path);
|
WriteToFile(U, Path);
|
||||||
Printf("Test unit written to %s\nBase64: ", Path.c_str());
|
Printf("Test unit written to %s\n", Path.c_str());
|
||||||
PrintFileAsBase64(Path);
|
if (U.size() <= kMaxUnitSizeToPrint) {
|
||||||
|
Printf("Base64: ");
|
||||||
|
PrintFileAsBase64(Path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fuzzer::SaveCorpus() {
|
void Fuzzer::SaveCorpus() {
|
||||||
|
|||||||
Reference in new issue
Block a user