Issue #2007: add filename extension to /crashes files

This is very helpful for code that inpects a file name extension when determining what code to run.

It's also useful for applications that constrain the user to choose files by extension.
This commit is contained in:
Sean McBride
2024-02-22 10:47:53 -05:00
parent 340d6aa97c
commit b2b887d04d
4 changed files with 50 additions and 23 deletions

View File

@ -2003,7 +2003,7 @@ afl_fsrv_run_target(afl_forkserver_t *fsrv, u32 timeout,
if (unlikely(fsrv->persistent_record)) {
retval = FSRV_RUN_TMOUT;
persistent_out_fmt = "%s/hangs/RECORD:%06u,cnt:%06u";
persistent_out_fmt = "%s/hangs/RECORD:%06u,cnt:%06u%s%s";
goto store_persistent_record;
}
@ -2039,7 +2039,7 @@ afl_fsrv_run_target(afl_forkserver_t *fsrv, u32 timeout,
if (unlikely(fsrv->persistent_record)) {
retval = FSRV_RUN_CRASH;
persistent_out_fmt = "%s/crashes/RECORD:%06u,cnt:%06u";
persistent_out_fmt = "%s/crashes/RECORD:%06u,cnt:%06u%s%s";
goto store_persistent_record;
}
@ -2066,7 +2066,9 @@ store_persistent_record: {
if (likely(len && data)) {
snprintf(fn, sizeof(fn), persistent_out_fmt, fsrv->persistent_record_dir,
fsrv->persistent_record_cnt, writecnt++);
fsrv->persistent_record_cnt, writecnt++,
afl->file_extension ? "." : "",
afl->file_extension ? (const char*)afl->file_extension : "");
int fd = open(fn, O_CREAT | O_TRUNC | O_WRONLY, 0644);
if (fd >= 0) {