Bug#227081: cp does not truncate existing destinations
Package: busybox-cvs
Version: 20040101-2
Severity: grave
Tags: patch
cp does not truncate existing destinations. That is, after
running
echo foo > foo
echo fubar > fubar
cp foo fubar
the contents of fubar are
foo
r
instead of
foo
This breaks debian-installer.
The attached patch fixes it.
--
Matt Kraai kraai@ftbfs.org
diff -ru busybox-cvs-20040101-old/libbb/copy_file.c busybox-cvs-20040101/libbb/copy_file.c
--- busybox-cvs-20040101-old/libbb/copy_file.c 2004-01-09 17:32:08.000000000 -0800
+++ busybox-cvs-20040101/libbb/copy_file.c 2004-01-09 17:39:09.000000000 -0800
@@ -153,7 +153,7 @@
}
}
- dst_fd = open(dest, O_WRONLY);
+ dst_fd = open(dest, O_WRONLY|O_TRUNC);
if (dst_fd == -1) {
if (!(flags & FILEUTILS_FORCE)) {
bb_perror_msg("unable to open `%s'", dest);
Reply to: