mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-15 11:28:08 +00:00
Add AFL_SHA1_FILENAMES
option
This commit is contained in:
@ -527,12 +527,24 @@ save_if_interesting(afl_state_t *afl, void *mem, u32 len, u8 fault) {
|
||||
|
||||
#ifndef SIMPLE_FILES
|
||||
|
||||
queue_fn = alloc_printf(
|
||||
"%s/queue/id:%06u,%s%s%s", afl->out_dir, afl->queued_items,
|
||||
describe_op(afl, new_bits + is_timeout,
|
||||
NAME_MAX - strlen("id:000000,")),
|
||||
afl->file_extension ? "." : "",
|
||||
afl->file_extension ? (const char *)afl->file_extension : "");
|
||||
if (!afl->afl_env.afl_sha1_filenames) {
|
||||
|
||||
queue_fn = alloc_printf(
|
||||
"%s/queue/id:%06u,%s%s%s", afl->out_dir, afl->queued_items,
|
||||
describe_op(afl, new_bits + is_timeout,
|
||||
NAME_MAX - strlen("id:000000,")),
|
||||
afl->file_extension ? "." : "",
|
||||
afl->file_extension ? (const char *)afl->file_extension : "");
|
||||
|
||||
} else {
|
||||
|
||||
const char *hex = sha1_hex(mem, len);
|
||||
queue_fn = alloc_printf(
|
||||
"%s/queue/%s%s%s", afl->out_dir, hex, afl->file_extension ? "." : "",
|
||||
afl->file_extension ? (const char *)afl->file_extension : "");
|
||||
ck_free((char *)hex);
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
@ -542,10 +554,14 @@ save_if_interesting(afl_state_t *afl, void *mem, u32 len, u8 fault) {
|
||||
afl->file_extension ? (const char *)afl->file_extension : "");
|
||||
|
||||
#endif /* ^!SIMPLE_FILES */
|
||||
fd = open(queue_fn, O_WRONLY | O_CREAT | O_EXCL, DEFAULT_PERMISSION);
|
||||
if (unlikely(fd < 0)) { PFATAL("Unable to create '%s'", queue_fn); }
|
||||
ck_write(fd, mem, len, queue_fn);
|
||||
close(fd);
|
||||
fd = permissive_create(afl, queue_fn);
|
||||
if (likely(fd >= 0)) {
|
||||
|
||||
ck_write(fd, mem, len, queue_fn);
|
||||
close(fd);
|
||||
|
||||
}
|
||||
|
||||
add_to_queue(afl, queue_fn, len, 0);
|
||||
|
||||
if (unlikely(afl->fuzz_mode) &&
|
||||
@ -743,11 +759,23 @@ save_if_interesting(afl_state_t *afl, void *mem, u32 len, u8 fault) {
|
||||
|
||||
#ifndef SIMPLE_FILES
|
||||
|
||||
snprintf(fn, PATH_MAX, "%s/hangs/id:%06llu,%s%s%s", afl->out_dir,
|
||||
afl->saved_hangs,
|
||||
describe_op(afl, 0, NAME_MAX - strlen("id:000000,")),
|
||||
afl->file_extension ? "." : "",
|
||||
afl->file_extension ? (const char *)afl->file_extension : "");
|
||||
if (!afl->afl_env.afl_sha1_filenames) {
|
||||
|
||||
snprintf(fn, PATH_MAX, "%s/hangs/id:%06llu,%s%s%s", afl->out_dir,
|
||||
afl->saved_hangs,
|
||||
describe_op(afl, 0, NAME_MAX - strlen("id:000000,")),
|
||||
afl->file_extension ? "." : "",
|
||||
afl->file_extension ? (const char *)afl->file_extension : "");
|
||||
|
||||
} else {
|
||||
|
||||
const char *hex = sha1_hex(mem, len);
|
||||
snprintf(fn, PATH_MAX, "%s/hangs/%s%s%s", afl->out_dir, hex,
|
||||
afl->file_extension ? "." : "",
|
||||
afl->file_extension ? (const char *)afl->file_extension : "");
|
||||
ck_free((char *)hex);
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
@ -799,11 +827,23 @@ save_if_interesting(afl_state_t *afl, void *mem, u32 len, u8 fault) {
|
||||
|
||||
#ifndef SIMPLE_FILES
|
||||
|
||||
snprintf(fn, PATH_MAX, "%s/crashes/id:%06llu,sig:%02u,%s%s%s",
|
||||
afl->out_dir, afl->saved_crashes, afl->fsrv.last_kill_signal,
|
||||
describe_op(afl, 0, NAME_MAX - strlen("id:000000,sig:00,")),
|
||||
afl->file_extension ? "." : "",
|
||||
afl->file_extension ? (const char *)afl->file_extension : "");
|
||||
if (!afl->afl_env.afl_sha1_filenames) {
|
||||
|
||||
snprintf(fn, PATH_MAX, "%s/crashes/id:%06llu,sig:%02u,%s%s%s",
|
||||
afl->out_dir, afl->saved_crashes, afl->fsrv.last_kill_signal,
|
||||
describe_op(afl, 0, NAME_MAX - strlen("id:000000,sig:00,")),
|
||||
afl->file_extension ? "." : "",
|
||||
afl->file_extension ? (const char *)afl->file_extension : "");
|
||||
|
||||
} else {
|
||||
|
||||
const char *hex = sha1_hex(mem, len);
|
||||
snprintf(fn, PATH_MAX, "%s/crashes/%s%s%s", afl->out_dir, hex,
|
||||
afl->file_extension ? "." : "",
|
||||
afl->file_extension ? (const char *)afl->file_extension : "");
|
||||
ck_free((char *)hex);
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
@ -873,10 +913,13 @@ save_if_interesting(afl_state_t *afl, void *mem, u32 len, u8 fault) {
|
||||
/* If we're here, we apparently want to save the crash or hang
|
||||
test case, too. */
|
||||
|
||||
fd = open(fn, O_WRONLY | O_CREAT | O_EXCL, DEFAULT_PERMISSION);
|
||||
if (unlikely(fd < 0)) { PFATAL("Unable to create '%s'", fn); }
|
||||
ck_write(fd, mem, len, fn);
|
||||
close(fd);
|
||||
fd = permissive_create(afl, fn);
|
||||
if (fd >= 0) {
|
||||
|
||||
ck_write(fd, mem, len, fn);
|
||||
close(fd);
|
||||
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
if (afl->fsrv.nyx_mode && fault == FSRV_RUN_CRASH) {
|
||||
|
Reference in New Issue
Block a user