diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2003-08-01 21:05:00 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2003-08-01 21:05:00 +0000 |
commit | 7a14321ae0fa969b3b13d7f06f0ddc12bc09acab (patch) | |
tree | a81bc4b711668790cff13e08d3df15ce863bdc1c /lib | |
parent | dee3aa75379c3e92377a4731bf2fc8f7a87a1dbb (diff) |
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')
-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); } |