summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMatt Kraai <kraai@debian.org>2001-04-27 15:40:27 +0000
committerMatt Kraai <kraai@debian.org>2001-04-27 15:40:27 +0000
commit72ab975a6b9c877add88e37557168a662b4250b0 (patch)
treeeda90244f72e29903f4b3856e9683aa25ee4297a
parent088875fec497e7f41f2257b4ac8c05560b391ff9 (diff)
Terminate source correctly when copying symlink. Report and patch by
Brian Webb <webbb@desertscenes.net>.
-rw-r--r--libbb/copy_file.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libbb/copy_file.c b/libbb/copy_file.c
index 4ee3efdbc..6c220022f 100644
--- a/libbb/copy_file.c
+++ b/libbb/copy_file.c
@@ -200,13 +200,14 @@ int copy_file(const char *source, const char *dest, int flags)
umask(saved_umask);
} else if (S_ISLNK(source_stat.st_mode)) {
+ int size;
char buf[BUFSIZ + 1];
- if (readlink(source, buf, BUFSIZ) < 0) {
+ if ((size = readlink(source, buf, BUFSIZ)) < 0) {
perror_msg("cannot read `%s'", source);
return -1;
}
- buf[BUFSIZ] = '\0';
+ buf[size] = '\0';
if (symlink(buf, dest) < 0) {
perror_msg("cannot create symlink `%s'", dest);