Truncate files written with "-o".

This commit is contained in:
Andrew Wood
2024-06-08 22:02:11 +01:00
parent 01e0290d6e
commit 2bed6776e4
3 changed files with 3 additions and 4 deletions
+1 -1
View File
@@ -306,7 +306,7 @@ int main(int argc, char **argv)
if (NULL == opts->output || 0 == strcmp(opts->output, "-")) {
pv_state_output_set(state, STDOUT_FILENO, "(stdout)");
} else {
int fd = open(opts->output, O_WRONLY | O_CREAT, 0600); /* flawfinder: ignore */
int fd = open(opts->output, O_WRONLY | O_CREAT | O_TRUNC, 0600); /* flawfinder: ignore */
/*
* flawfinder rationale: the output filename has been
* explicitly provided, and in many cases the operator will