aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorkraai <kraai@69ca8d6d-28ef-0310-b511-8ec308f3f277>2001-04-27 15:40:27 +0000
committerkraai <kraai@69ca8d6d-28ef-0310-b511-8ec308f3f277>2001-04-27 15:40:27 +0000
commiteece635c1b12996367cc5f11bb3d52c3ca7b70ba (patch)
treeeda90244f72e29903f4b3856e9683aa25ee4297a /libbb
parent07c93581560b2f0f612e9da999673412eeb631dc (diff)
downloadbusybox-w32-eece635c1b12996367cc5f11bb3d52c3ca7b70ba.tar.gz
busybox-w32-eece635c1b12996367cc5f11bb3d52c3ca7b70ba.tar.bz2
busybox-w32-eece635c1b12996367cc5f11bb3d52c3ca7b70ba.zip
Terminate source correctly when copying symlink. Report and patch by
Brian Webb <webbb@desertscenes.net>. git-svn-id: svn://busybox.net/trunk/busybox@2478 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'libbb')
-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)
200 200
201 umask(saved_umask); 201 umask(saved_umask);
202 } else if (S_ISLNK(source_stat.st_mode)) { 202 } else if (S_ISLNK(source_stat.st_mode)) {
203 int size;
203 char buf[BUFSIZ + 1]; 204 char buf[BUFSIZ + 1];
204 205
205 if (readlink(source, buf, BUFSIZ) < 0) { 206 if ((size = readlink(source, buf, BUFSIZ)) < 0) {
206 perror_msg("cannot read `%s'", source); 207 perror_msg("cannot read `%s'", source);
207 return -1; 208 return -1;
208 } 209 }
209 buf[BUFSIZ] = '\0'; 210 buf[size] = '\0';
210 211
211 if (symlink(buf, dest) < 0) { 212 if (symlink(buf, dest) < 0) {
212 perror_msg("cannot create symlink `%s'", dest); 213 perror_msg("cannot create symlink `%s'", dest);