summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>1998-05-18 09:55:19 +0000
committerderaadt <deraadt@openbsd.org>1998-05-18 09:55:19 +0000
commita98daa6924e11ed7ecb2b2a8158f8bafc496d1dc (patch)
tree3e6fc4a8de981fccb7469575c7d7ef0018b3aad2
parentipfstat does not read from /vmunix (diff)
downloadwireguard-openbsd-a98daa6924e11ed7ecb2b2a8158f8bafc496d1dc.tar.xz
wireguard-openbsd-a98daa6924e11ed7ecb2b2a8158f8bafc496d1dc.zip
readlink(path, buf, sizeof buf-1). Never forget that -1.
-rw-r--r--bin/cp/utils.c6
-rw-r--r--lib/libc/stdlib/realpath.c4
-rw-r--r--libexec/mail.local/mail.local.c4
3 files changed, 7 insertions, 7 deletions
diff --git a/bin/cp/utils.c b/bin/cp/utils.c
index d6b606cd47e..9a9a18b79ce 100644
--- a/bin/cp/utils.c
+++ b/bin/cp/utils.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: utils.c,v 1.10 1997/11/08 23:17:12 todd Exp $ */
+/* $OpenBSD: utils.c,v 1.11 1998/05/18 09:58:05 deraadt Exp $ */
/* $NetBSD: utils.c,v 1.6 1997/02/26 14:40:51 cgd Exp $ */
/*-
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)utils.c 8.3 (Berkeley) 4/1/94";
#else
-static char rcsid[] = "$OpenBSD: utils.c,v 1.10 1997/11/08 23:17:12 todd Exp $";
+static char rcsid[] = "$OpenBSD: utils.c,v 1.11 1998/05/18 09:58:05 deraadt Exp $";
#endif
#endif /* not lint */
@@ -187,7 +187,7 @@ copy_link(p, exists)
int len;
char link[MAXPATHLEN];
- if ((len = readlink(p->fts_path, link, sizeof(link))) == -1) {
+ if ((len = readlink(p->fts_path, link, sizeof(link)-1)) == -1) {
warn("readlink: %s", p->fts_path);
return (1);
}
diff --git a/lib/libc/stdlib/realpath.c b/lib/libc/stdlib/realpath.c
index 78c286014dc..02886014649 100644
--- a/lib/libc/stdlib/realpath.c
+++ b/lib/libc/stdlib/realpath.c
@@ -35,7 +35,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: realpath.c,v 1.3 1997/06/20 20:37:45 deraadt Exp $";
+static char *rcsid = "$OpenBSD: realpath.c,v 1.4 1998/05/18 09:55:19 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@@ -105,7 +105,7 @@ loop:
errno = ELOOP;
goto err1;
}
- n = readlink(p, resolved, MAXPATHLEN);
+ n = readlink(p, resolved, MAXPATHLEN-1);
if (n < 0)
goto err1;
resolved[n] = '\0';
diff --git a/libexec/mail.local/mail.local.c b/libexec/mail.local/mail.local.c
index e77536d5bf8..dd59d84813a 100644
--- a/libexec/mail.local/mail.local.c
+++ b/libexec/mail.local/mail.local.c
@@ -39,7 +39,7 @@ char copyright[] =
#ifndef lint
/*static char sccsid[] = "from: @(#)mail.local.c 5.6 (Berkeley) 6/19/91";*/
-static char rcsid[] = "$Id: mail.local.c,v 1.17 1997/08/13 21:09:27 dm Exp $";
+static char rcsid[] = "$Id: mail.local.c,v 1.18 1998/05/18 09:58:03 deraadt Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -279,7 +279,7 @@ getlock(name, pw)
* or directories or symbolic links that
* should not be here.
*/
- if (readlink(lpath, buf, sizeof buf) != -1) {
+ if (readlink(lpath, buf, sizeof buf-1) != -1) {
if (lstat(lpath, &sb) != -1 &&
S_ISLNK(fsb.st_mode)) {
seteuid(sb.st_uid);