Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support exit_on_time option: issue #399 #487

Merged
merged 1 commit into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cmdline.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ bool cmdlineParse(int argc, char* argv[], honggfuzz_t* hfuzz) {
{ { "pprocess_cmd", required_argument, NULL, 0x111 }, "External command postprocessing files produced by internal mutators" },
{ { "ffmutate_cmd", required_argument, NULL, 0x110 }, "External command mutating files which have effective coverage feedback" },
{ { "run_time", required_argument, NULL, 0x109 }, "Number of seconds this fuzzing session will last (default: 0 [no limit])" },
{ { "exit_on_time", required_argument, NULL, 0x10A }, "Stop fuzzing session if no new coverage was found for this number of seconds (default: 0 [no limit])" },
{ { "iterations", required_argument, NULL, 'N' }, "Number of fuzzing iterations (default: 0 [no limit])" },
{ { "rlimit_as", required_argument, NULL, 0x100 }, "Per process RLIMIT_AS in MiB (default: 0 [default limit])" },
{ { "rlimit_rss", required_argument, NULL, 0x101 }, "Per process RLIMIT_RSS in MiB (default: 0 [default limit]). It will also set *SAN's soft_rss_limit_mb" },
Expand Down Expand Up @@ -688,6 +689,9 @@ bool cmdlineParse(int argc, char* argv[], honggfuzz_t* hfuzz) {
hfuzz->timing.runEndTime = time(NULL) + p;
}
} break;
case 0x10A:
hfuzz->timing.exitOnTime = atol(optarg);
break;
case 'N':
hfuzz->mutate.mutationsMax = atol(optarg);
break;
Expand Down
5 changes: 5 additions & 0 deletions honggfuzz.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,11 @@ static uint8_t mainThreadLoop(honggfuzz_t* hfuzz) {
LOG_I("Maximum run time reached, terminating");
break;
}
if (hfuzz->timing.exitOnTime > 0 &&
time(NULL) - ATOMIC_GET(hfuzz->timing.lastCovUpdate) > hfuzz->timing.exitOnTime) {
LOG_I("No new coverage was found for the last %ld seconds, terminating", hfuzz->timing.exitOnTime);
break;
}
pingThreads(hfuzz);
pause();
}
Expand Down
1 change: 1 addition & 0 deletions honggfuzz.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ typedef struct {
time_t runEndTime;
time_t tmOut;
time_t lastCovUpdate;
time_t exitOnTime;
int64_t timeOfLongestUnitUSecs;
bool tmoutVTALRM;
} timing;
Expand Down