summaryrefslogtreecommitdiff
path: root/fuzz.c
diff options
context:
space:
mode:
authorRobert Swiecki <robert@swiecki.net>2018-01-12 02:30:14 +0100
committerRobert Swiecki <robert@swiecki.net>2018-01-12 02:30:14 +0100
commit965af7f53fe5f065bc76263d0f3383f99eb664a3 (patch)
tree26d79ce21686d83257690f8c9d967f80a5436b44 /fuzz.c
parentfff99812642a7eb30f127c5f84110e7a2b5e6bd3 (diff)
downloadhonggfuzz-965af7f53fe5f065bc76263d0f3383f99eb664a3.tar.gz
fuzz: leave the original file in place after verification, so subsequent fuzzing will not report old findings as new
Diffstat (limited to 'fuzz.c')
-rw-r--r--fuzz.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/fuzz.c b/fuzz.c
index f0014f1a..0c4c6cc4 100644
--- a/fuzz.c
+++ b/fuzz.c
@@ -403,11 +403,7 @@ static bool fuzz_runVerifier(run_t* run) {
snprintf(verFile, sizeof(verFile), "%s.verified", origCrashPath);
if (files_exists(verFile)) {
- LOG_D("Crash file to verify '%s' is already verified as '%s'. Removing it", origCrashPath,
- verFile);
- if (unlink(origCrashPath) == -1) {
- PLOG_E("unlink('%s')", origCrashPath);
- }
+ LOG_D("Crash file to verify '%s' is already verified as '%s'", origCrashPath, verFile);
return false;
}
@@ -441,10 +437,10 @@ static bool fuzz_runVerifier(run_t* run) {
PLOG_E("Couldn't create '%s'", verFile);
return true;
}
- close(fd);
-
- if (rename(origCrashPath, verFile) == -1) {
- PLOG_E("rename('%s', '%s')", origCrashPath, verFile);
+ defer { close(fd); }
+ if (!files_writeToFd(fd, run->dynamicFile, run->dynamicFileSz)) {
+ LOG_E("Couldn't save verified file as '%s'", verFile);
+ unlink(verFile);
return true;
}