Skip to content

Commit

Permalink
make indent
Browse files Browse the repository at this point in the history
  • Loading branch information
robertswiecki committed Sep 15, 2023
1 parent 7f43e90 commit bc49df3
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 27 deletions.
27 changes: 14 additions & 13 deletions fuzz.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,32 +239,33 @@ static void fuzz_perfFeedback(run_t* run) {
run->hwCnts.bbCnt, softCurEdge, softCurPC, softCurCmp);

if (run->global->io.statsFileName) {
const time_t curr_sec = time(NULL);
const time_t elapsed_sec = curr_sec - run->global->timing.timeStart;
size_t curr_exec_cnt = ATOMIC_GET(run->global->cnts.mutationsCnt);
const time_t curr_sec = time(NULL);
const time_t elapsed_sec = curr_sec - run->global->timing.timeStart;
size_t curr_exec_cnt = ATOMIC_GET(run->global->cnts.mutationsCnt);
/*
* We increase the mutation counter unconditionally in threads, but if it's
* above hfuzz->mutationsMax we don't really execute the fuzzing loop.
* Therefore at the end of fuzzing, the mutation counter might be higher
* than hfuzz->mutationsMax
*/
if (run->global->mutate.mutationsMax > 0 && curr_exec_cnt > run->global->mutate.mutationsMax) {
if (run->global->mutate.mutationsMax > 0 &&
curr_exec_cnt > run->global->mutate.mutationsMax) {
curr_exec_cnt = run->global->mutate.mutationsMax;
}
size_t tot_exec_per_sec = elapsed_sec ? (curr_exec_cnt / elapsed_sec) : 0;

dprintf(run->global->io.statsFileFd,
"%lu, %lu, %lu, %lu, "
"%" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 "\n",
curr_sec, /* unix_time */
run->global->timing.lastCovUpdate, /* last_cov_update */
curr_exec_cnt, /* total_exec */
tot_exec_per_sec, /* exec_per_sec */
run->global->cnts.crashesCnt, /* crashes */
run->global->cnts.uniqueCrashesCnt, /* unique_crashes */
run->global->cnts.timeoutedCnt, /* hangs */
run->global->feedback.hwCnts.softCntEdge, /* edge_cov */
run->global->feedback.hwCnts.softCntPc /* block_cov */
curr_sec, /* unix_time */
run->global->timing.lastCovUpdate, /* last_cov_update */
curr_exec_cnt, /* total_exec */
tot_exec_per_sec, /* exec_per_sec */
run->global->cnts.crashesCnt, /* crashes */
run->global->cnts.uniqueCrashesCnt, /* unique_crashes */
run->global->cnts.timeoutedCnt, /* hangs */
run->global->feedback.hwCnts.softCntEdge, /* edge_cov */
run->global->feedback.hwCnts.softCntPc /* block_cov */
);
}

Expand Down
6 changes: 4 additions & 2 deletions honggfuzz.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,12 +418,14 @@ int main(int argc, char** argv) {
}
/* Stats file. */
if (hfuzz.io.statsFileName) {
hfuzz.io.statsFileFd = TEMP_FAILURE_RETRY(open(hfuzz.io.statsFileName, O_CREAT | O_RDWR | O_TRUNC, 0640));
hfuzz.io.statsFileFd =
TEMP_FAILURE_RETRY(open(hfuzz.io.statsFileName, O_CREAT | O_RDWR | O_TRUNC, 0640));

if (hfuzz.io.statsFileFd == -1) {
PLOG_F("Couldn't open statsfile open('%s')", hfuzz.io.statsFileName);
} else {
dprintf(hfuzz.io.statsFileFd, "# unix_time, last_cov_update, total_exec, exec_per_sec, crashes, unique_crashes, hangs, edge_cov, block_cov\n");
dprintf(hfuzz.io.statsFileFd, "# unix_time, last_cov_update, total_exec, exec_per_sec, "
"crashes, unique_crashes, hangs, edge_cov, block_cov\n");
}
}

Expand Down
4 changes: 2 additions & 2 deletions honggfuzz.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,10 @@ typedef struct {
dynfile_t* dynfileqCurrent;
dynfile_t* dynfileq2Current;
TAILQ_HEAD(dyns_t, _dynfile_t) dynfileq;
bool exportFeedback;
bool exportFeedback;
const char* dynamicInputDir;
const char* statsFileName;
int statsFileFd;
int statsFileFd;
} io;
struct {
int argc;
Expand Down
18 changes: 10 additions & 8 deletions input.c
Original file line number Diff line number Diff line change
Expand Up @@ -575,12 +575,12 @@ bool input_prepareDynamicInput(run_t* run, bool needs_mangle) {
return true;
}

bool input_dynamicQueueGetNext(char fname[PATH_MAX], DIR* dynamicDirPtr, char *dynamicWorkDir) {
bool input_dynamicQueueGetNext(char fname[PATH_MAX], DIR* dynamicDirPtr, char* dynamicWorkDir) {
static pthread_mutex_t input_mutex = PTHREAD_MUTEX_INITIALIZER;
MX_SCOPED_LOCK(&input_mutex);

for (;;) {
errno = 0;
errno = 0;
struct dirent* entry = readdir(dynamicDirPtr);
if (entry == NULL && errno == EINTR) {
continue;
Expand Down Expand Up @@ -641,7 +641,7 @@ void input_enqueueDynamicInputs(honggfuzz_t* hfuzz) {

/* Get file status. */
struct stat dynamicFileStat;
size_t dynamicFileSz;
size_t dynamicFileSz;

if (fstat(dynamicFileFd, &dynamicFileStat) == -1) {
PLOG_E("Error getting file status: %s", dynamicInputFileName);
Expand All @@ -651,7 +651,8 @@ void input_enqueueDynamicInputs(honggfuzz_t* hfuzz) {

dynamicFileSz = dynamicFileStat.st_size;

uint8_t* dynamicFile = (uint8_t *) mmap(NULL, dynamicFileSz, PROT_READ | PROT_WRITE, MAP_SHARED, dynamicFileFd, 0);
uint8_t* dynamicFile = (uint8_t*)mmap(
NULL, dynamicFileSz, PROT_READ | PROT_WRITE, MAP_SHARED, dynamicFileFd, 0);

if (dynamicFile == MAP_FAILED) {
PLOG_E("Error mapping dynamic input file: %s", dynamicInputFileName);
Expand All @@ -662,7 +663,7 @@ void input_enqueueDynamicInputs(honggfuzz_t* hfuzz) {
LOG_I("Loading dynamic input file: %s (%lu)", dynamicInputFileName, dynamicFileSz);

run_t tmp_run;
tmp_run.global = hfuzz;
tmp_run.global = hfuzz;
dynfile_t tmp_dynfile = {
.size = dynamicFileSz,
.cov = {0xff, 0xff, 0xff, 0xff},
Expand All @@ -672,14 +673,15 @@ void input_enqueueDynamicInputs(honggfuzz_t* hfuzz) {
.path = "",
.data = dynamicFile,
};
tmp_run.timeStartedUSecs = util_timeNowUSecs() -1;
tmp_run.timeStartedUSecs = util_timeNowUSecs() - 1;
memcpy(tmp_dynfile.path, dynamicInputFileName, PATH_MAX);
tmp_run.dynfile = &tmp_dynfile;
input_addDynamicInput(&tmp_run);
//input_addDynamicInput(hfuzz, dynamicFile, dynamicFileSz, (uint64_t[4]){0xff, 0xff, 0xff, 0xff}, dynamicInputFileName);
// input_addDynamicInput(hfuzz, dynamicFile, dynamicFileSz, (uint64_t[4]){0xff, 0xff, 0xff,
// 0xff}, dynamicInputFileName);

/* Unmap input file. */
if (munmap((void *) dynamicFile, dynamicFileSz) == -1) {
if (munmap((void*)dynamicFile, dynamicFileSz) == -1) {
PLOG_E("Error unmapping input file!");
}

Expand Down
5 changes: 3 additions & 2 deletions input.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ extern bool input_removeStaticFile(const char* dir, const char* name);
extern bool input_prepareExternalFile(run_t* run);
extern bool input_postProcessFile(run_t* run, const char* cmd);
extern bool input_prepareDynamicFileForMinimization(run_t* run);
extern bool input_dynamicQueueGetNext(char fname[PATH_MAX], DIR* dynamicDirPtr, char *dynamicWorkDir);
extern void input_enqueueDynamicInputs(honggfuzz_t* hfuzz);
extern bool input_dynamicQueueGetNext(
char fname[PATH_MAX], DIR* dynamicDirPtr, char* dynamicWorkDir);
extern void input_enqueueDynamicInputs(honggfuzz_t* hfuzz);

#endif /* ifndef _HF_INPUT_H_ */

0 comments on commit bc49df3

Please sign in to comment.