From 59557e1c9ca33c997743c0c03cf73c2f470c8bf3 Mon Sep 17 00:00:00 2001 From: Rajesh Joseph Date: Wed, 9 Sep 2015 17:46:16 +0530 Subject: glusterd/utils: glusterd_copy_file does not truncate target file glusterd_copy_file function copies source file to target. If the target file already exists and is bigger than the source file then it can cause file corruption. Target file should be truncated before copying source content. Signed-off-by: Rajesh Joseph Change-Id: Ie973f3e9fa06309ded6f69dcde41e1b60b3e028e BUG: 1261482 Reviewed-on: http://review.gluster.org/12141 Reviewed-by: jiffin tony Thottan Tested-by: NetBSD Build System Tested-by: Gluster Build System Reviewed-by: Atin Mukherjee --- xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c index 23fae9add57..5833e5ec593 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c @@ -3234,7 +3234,7 @@ glusterd_copy_file (const char *source, const char *destination) goto out; } - dest_fd = open (destination, O_CREAT | O_RDWR, dest_mode); + dest_fd = creat (destination, dest_mode); if (dest_fd < 0) { ret = -1; gf_msg (this->name, GF_LOG_ERROR, 0, -- cgit