Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow --save-smaller to overwrite #380

Merged
merged 1 commit into from
Feb 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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