Skip to content

Commit

Permalink
Merge pull request #380 from catalyst/save-smaller-fixed
Browse files Browse the repository at this point in the history
allow --save-smaller to overwrite
  • Loading branch information
robertswiecki committed Feb 9, 2021
2 parents 54ae3d1 + aec73c6 commit d20bfd6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion linux/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ static void arch_traceSaveData(run_t* run, pid_t pid) {
crashAddr = 0UL;
}

int open_flags = O_CREAT | O_EXCL | O_WRONLY | O_CLOEXEC;
uint64_t pc = 0;
uint64_t status_reg = 0;
size_t pcRegSz = arch_getPC(pid, &pc, &status_reg);
Expand Down Expand Up @@ -729,6 +730,9 @@ static void arch_traceSaveData(run_t* run, pid_t pid) {
snprintf(origFile, sizeof(origFile), "%s.orig", run->crashFileName);
if (!files_exists(origFile)) {
rename(run->crashFileName, origFile);
} else {
/* allow overwrite */
open_flags = O_CREAT | O_WRONLY | O_CLOEXEC;
}
} else {
LOG_I("Crash (dup): '%s' already exists, skipping", run->crashFileName);
Expand All @@ -739,7 +743,7 @@ static void arch_traceSaveData(run_t* run, pid_t pid) {
}

if (!files_writeBufToFile(run->crashFileName, run->dynfile->data, run->dynfile->size,
O_CREAT | O_EXCL | O_WRONLY | O_CLOEXEC)) {
open_flags)) {
LOG_E("Couldn't write to '%s'", run->crashFileName);
return;
}
Expand Down

0 comments on commit d20bfd6

Please sign in to comment.