summaryrefslogtreecommitdiffstats
path: root/usr.bin/rdistd
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2009-03-28 15:18:29 +0000
committerderaadt <deraadt@openbsd.org>2009-03-28 15:18:29 +0000
commit3d7ae6a09f87d5fe33d192d1ba75378de30c715b (patch)
tree3031ba793b84bd4206d5b7d6857eead3d99dfddf /usr.bin/rdistd
parentuse a static and unique string as the disk lock name, so if we're waiting (diff)
downloadwireguard-openbsd-3d7ae6a09f87d5fe33d192d1ba75378de30c715b.tar.xz
wireguard-openbsd-3d7ae6a09f87d5fe33d192d1ba75378de30c715b.zip
pathnames with space, tab, newline, etc are encoded before being sent.
But they were not reliably being decoded, resulting in wrong naming on the target machine. diff from Tim van der Molen
Diffstat (limited to 'usr.bin/rdistd')
-rw-r--r--usr.bin/rdistd/server.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/usr.bin/rdistd/server.c b/usr.bin/rdistd/server.c
index d5d2799dcb3..dd15e834084 100644
--- a/usr.bin/rdistd/server.c
+++ b/usr.bin/rdistd/server.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server.c,v 1.19 2008/05/25 22:33:56 millert Exp $ */
+/* $OpenBSD: server.c,v 1.20 2009/03/28 15:18:29 deraadt Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
@@ -36,7 +36,7 @@ static char RCSid[] __attribute__((__unused__)) =
"$From: server.c,v 1.10 1999/08/04 15:57:33 christos Exp $";
#else
static char RCSid[] __attribute__((__unused__)) =
-"$OpenBSD: server.c,v 1.19 2008/05/25 22:33:56 millert Exp $";
+"$OpenBSD: server.c,v 1.20 2009/03/28 15:18:29 deraadt Exp $";
#endif
static char sccsid[] __attribute__((__unused__)) =
@@ -1163,7 +1163,7 @@ recvdir(opt_t opts, int mode, char *owner, char *group)
static void
recvlink(char *new, opt_t opts, int mode, off_t size)
{
- char tbuf[MAXPATHLEN];
+ char tbuf[MAXPATHLEN], dbuf[BUFSIZ];
struct stat stb;
char *optarget;
int uptodate;
@@ -1180,10 +1180,15 @@ recvlink(char *new, opt_t opts, int mode, off_t size)
return;
}
+ if (DECODE(dbuf, buf) == -1) {
+ error("recvlink: cannot decode symlink target");
+ return;
+ }
+
uptodate = 0;
if ((i = readlink(target, tbuf, sizeof(tbuf)-1)) != -1) {
tbuf[i] = '\0';
- if (i == size && strncmp(buf, tbuf, (int) size) == 0)
+ if (i == size && strncmp(dbuf, tbuf, (int) size) == 0)
uptodate = 1;
}
mode &= 0777;
@@ -1204,10 +1209,11 @@ recvlink(char *new, opt_t opts, int mode, off_t size)
/*
* Make new symlink using a temporary name
*/
- if (mktemp(new) == NULL || symlink(buf, new) < 0) {
+ if (mktemp(new) == NULL || symlink(dbuf, new) < 0) {
if (errno != ENOENT || chkparent(new, opts) < 0 ||
- mktemp(new) == NULL || symlink(buf, new) < 0) {
- error("%s -> %s: symlink failed: %s", new, buf, SYSERR);
+ mktemp(new) == NULL || symlink(dbuf, new) < 0) {
+ error("%s -> %s: symlink failed: %s", new, dbuf,
+ SYSERR);
return;
}
}