diff options
author | 2003-08-01 21:04:59 +0000 | |
---|---|---|
committer | 2003-08-01 21:04:59 +0000 | |
commit | a0a346ce2464298339af3dfb0cfaf0af42e47a60 (patch) | |
tree | efc969c6a516c4a318718a28945d4eb18f5e6b7f /lib/libc/stdlib/realpath.c | |
parent | anychange is no longer extern; millert ok (diff) | |
download | wireguard-openbsd-a0a346ce2464298339af3dfb0cfaf0af42e47a60.tar.xz wireguard-openbsd-a0a346ce2464298339af3dfb0cfaf0af42e47a60.zip |
Rename rootd to needslash and invert its value. This fixes the check
for ENAMETOOLONG, though since we use strlcpy() and strlcat() this
is not a big deal. Problem found by vincent@
Diffstat (limited to 'lib/libc/stdlib/realpath.c')
-rw-r--r-- | lib/libc/stdlib/realpath.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/libc/stdlib/realpath.c b/lib/libc/stdlib/realpath.c index 0accd227aa1..1525d0372f2 100644 --- a/lib/libc/stdlib/realpath.c +++ b/lib/libc/stdlib/realpath.c @@ -31,7 +31,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: realpath.c,v 1.9 2003/06/02 20:18:38 millert Exp $"; +static char *rcsid = "$OpenBSD: realpath.c,v 1.10 2003/08/01 21:04:59 millert Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/param.h> @@ -56,7 +56,7 @@ realpath(path, resolved) char *resolved; { struct stat sb; - int fd, n, rootd, serrno; + int fd, n, needslash, serrno; char *p, *q, wbuf[MAXPATHLEN]; int symlinks = 0; @@ -130,16 +130,16 @@ loop: * happens if the last component is empty, or the dirname is root. */ if (resolved[0] == '/' && resolved[1] == '\0') - rootd = 1; + needslash = 0; else - rootd = 0; + needslash = 1; if (*wbuf) { - if (strlen(resolved) + strlen(wbuf) + rootd + 1 > MAXPATHLEN) { + if (strlen(resolved) + strlen(wbuf) + needslash >= MAXPATHLEN) { errno = ENAMETOOLONG; goto err1; } - if (rootd == 0) + if (needslash) strlcat(resolved, "/", MAXPATHLEN); strlcat(resolved, wbuf, MAXPATHLEN); } |