From: Joel Rosdahl Date: Fri, 29 May 2020 18:38:26 +0000 (+0200) Subject: Add missing O_TRUNC when opening destination file X-Git-Tag: v3.7.10~6 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=f2b4d05de722f58807fdf2518003515b143a26e3;p=thirdparty%2Fccache.git Add missing O_TRUNC when opening destination file Should have been there in a16778a6243e271d501da95232cbe7c9ff58649b. --- diff --git a/src/util.c b/src/util.c index eff2eed02..4aa99f424 100644 --- a/src/util.c +++ b/src/util.c @@ -333,7 +333,7 @@ copy_file(const char *src, cc_log("Copying %s to %s via %s (%scompressed)", src, dest, tmp_name, compress_level > 0 ? "" : "un"); } else { - fd_out = open(dest, O_WRONLY | O_CREAT | O_BINARY, 0666); + fd_out = open(dest, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666); if (fd_out == -1) { saved_errno = errno; close(fd_out);