summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>1998-06-09 04:10:08 +0000
committerimp <imp@FreeBSD.org>1998-06-09 04:10:08 +0000
commit41a9e1ce2d103396468b07dce9965543cd39f4db (patch)
treeca543152855926f88ede31b4e3ad1547a44c5865 /usr.bin
parent276491a1c64f083aea60c7a82138eedcef34afd5 (diff)
downloadFreeBSD-src-41a9e1ce2d103396468b07dce9965543cd39f4db.zip
FreeBSD-src-41a9e1ce2d103396468b07dce9965543cd39f4db.tar.gz
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
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/find/ls.c2
-rw-r--r--usr.bin/rdist/server.c6
2 files changed, 4 insertions, 4 deletions
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 <sys/wait.h>
@@ -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();
OpenPOWER on IntegriCloud