]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Add missing O_TRUNC in copy_file and clone_file
authorJoel Rosdahl <joel@rosdahl.net>
Fri, 29 May 2020 18:53:22 +0000 (20:53 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Fri, 29 May 2020 19:09:06 +0000 (21:09 +0200)
src/legacy_util.cpp

index bd0fde6ddbc232506927e4cea38818ffe889a4e8..2db39c4f62f23d97e57da8a2b4bfba226d1b5958 100644 (file)
@@ -162,7 +162,7 @@ clone_file(const char* src, const char* dest, bool via_tmp_file)
     tmp_file = x_strdup(dest);
     dest_fd = create_tmp_fd(&tmp_file);
   } else {
-    dest_fd = open(dest, O_WRONLY | O_CREAT | O_BINARY, 0666);
+    dest_fd = open(dest, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
     if (dest_fd == -1) {
       close(dest_fd);
       close(src_fd);
@@ -225,7 +225,7 @@ copy_file(const char* src, const char* dest, bool via_tmp_file)
     tmp_file = x_strdup(dest);
     dest_fd = create_tmp_fd(&tmp_file);
   } else {
-    dest_fd = open(dest, O_WRONLY | O_CREAT | O_BINARY, 0666);
+    dest_fd = open(dest, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
     if (dest_fd == -1) {
       close(dest_fd);
       close(src_fd);