Skip to content

Commit 1d28127

Browse files
cgzoneshallyn
authored andcommitted
Fail if regular file pre-exists in copy_tree()
Similar to the default behavior of mkdir(2), symlink(2), link(2) and mknod(2).
1 parent dab764d commit 1d28127

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

libmisc/copydir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ static int copy_file (const char *src, const char *dst,
723723
return -1;
724724
}
725725
#endif /* WITH_SELINUX */
726-
ofd = open (dst, O_WRONLY | O_CREAT | O_TRUNC | O_NOFOLLOW, statp->st_mode & 07777);
726+
ofd = open (dst, O_WRONLY | O_CREAT | O_EXCL | O_TRUNC | O_NOFOLLOW | O_CLOEXEC, statp->st_mode & 07777);
727727
if ( (ofd < 0)
728728
|| (fchown_if_needed (ofd, statp,
729729
old_uid, new_uid, old_gid, new_gid) != 0)

0 commit comments

Comments
 (0)