From 41a9e1ce2d103396468b07dce9965543cd39f4db Mon Sep 17 00:00:00 2001 From: imp Date: Tue, 9 Jun 1998 04:10:08 +0000 Subject: Make sure we pass the length - 1 to readlink, since it adds its own NUL at the end of the path. Inspired by: OpenBSD's changes in this area by theo de raadt --- usr.bin/find/ls.c | 2 +- usr.bin/rdist/server.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/find/ls.c b/usr.bin/find/ls.c index 29c068d..a1b9dd7 100644 --- a/usr.bin/find/ls.c +++ b/usr.bin/find/ls.c @@ -107,7 +107,7 @@ printlink(name) int lnklen; char path[MAXPATHLEN + 1]; - if ((lnklen = readlink(name, path, MAXPATHLEN)) == -1) { + if ((lnklen = readlink(name, path, MAXPATHLEN - 1)) == -1) { warn("%s", name); return; } diff --git a/usr.bin/rdist/server.c b/usr.bin/rdist/server.c index 98b1e4a..d91d723 100644 --- a/usr.bin/rdist/server.c +++ b/usr.bin/rdist/server.c @@ -36,7 +36,7 @@ static char sccsid[] = "@(#)server.c 8.1 (Berkeley) 6/9/93"; #endif static const char rcsid[] = - "$Id: server.c,v 1.7 1998/04/06 06:18:32 charnier Exp $"; + "$Id: server.c,v 1.8 1998/04/20 06:20:24 charnier Exp $"; #endif /* not lint */ #include @@ -473,7 +473,7 @@ sendf(rname, opts) (void) write(rem, buf, strlen(buf)); if (response() < 0) return; - sizerr = (readlink(target, buf, BUFSIZ) != stb.st_size); + sizerr = (readlink(target, buf, BUFSIZ - 1) != stb.st_size); (void) write(rem, buf, stb.st_size); if (debug) printf("readlink = %.*s\n", (int)stb.st_size, buf); @@ -870,7 +870,7 @@ recvf(cmd, type) if (opts & COMPARE) { char tbuf[BUFSIZ]; - if ((i = readlink(target, tbuf, BUFSIZ)) >= 0 && + if ((i = readlink(target, tbuf, BUFSIZ - 1)) >= 0 && i == size && strncmp(buf, tbuf, size) == 0) { (void) unlink(new); ack(); -- cgit v1.1