]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Add missing O_TRUNC when opening destination file
authorJoel Rosdahl <joel@rosdahl.net>
Fri, 29 May 2020 18:38:26 +0000 (20:38 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Fri, 29 May 2020 18:38:26 +0000 (20:38 +0200)
Should have been there in a16778a6243e271d501da95232cbe7c9ff58649b.

src/util.c

index eff2eed02f1ab026c072e1a7aa1307a355eba6d8..4aa99f424f7b3a854baee3d889aca65b837f8a46 100644 (file)
@@ -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);