diff options
Diffstat (limited to 'src/lib/libc/stdlib/realpath.c')
| -rw-r--r-- | src/lib/libc/stdlib/realpath.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/lib/libc/stdlib/realpath.c b/src/lib/libc/stdlib/realpath.c index 0accd227aa..1525d0372f 100644 --- a/src/lib/libc/stdlib/realpath.c +++ b/src/lib/libc/stdlib/realpath.c | |||
| @@ -31,7 +31,7 @@ | |||
| 31 | */ | 31 | */ |
| 32 | 32 | ||
| 33 | #if defined(LIBC_SCCS) && !defined(lint) | 33 | #if defined(LIBC_SCCS) && !defined(lint) |
| 34 | static char *rcsid = "$OpenBSD: realpath.c,v 1.9 2003/06/02 20:18:38 millert Exp $"; | 34 | static char *rcsid = "$OpenBSD: realpath.c,v 1.10 2003/08/01 21:04:59 millert Exp $"; |
| 35 | #endif /* LIBC_SCCS and not lint */ | 35 | #endif /* LIBC_SCCS and not lint */ |
| 36 | 36 | ||
| 37 | #include <sys/param.h> | 37 | #include <sys/param.h> |
| @@ -56,7 +56,7 @@ realpath(path, resolved) | |||
| 56 | char *resolved; | 56 | char *resolved; |
| 57 | { | 57 | { |
| 58 | struct stat sb; | 58 | struct stat sb; |
| 59 | int fd, n, rootd, serrno; | 59 | int fd, n, needslash, serrno; |
| 60 | char *p, *q, wbuf[MAXPATHLEN]; | 60 | char *p, *q, wbuf[MAXPATHLEN]; |
| 61 | int symlinks = 0; | 61 | int symlinks = 0; |
| 62 | 62 | ||
| @@ -130,16 +130,16 @@ loop: | |||
| 130 | * happens if the last component is empty, or the dirname is root. | 130 | * happens if the last component is empty, or the dirname is root. |
| 131 | */ | 131 | */ |
| 132 | if (resolved[0] == '/' && resolved[1] == '\0') | 132 | if (resolved[0] == '/' && resolved[1] == '\0') |
| 133 | rootd = 1; | 133 | needslash = 0; |
| 134 | else | 134 | else |
| 135 | rootd = 0; | 135 | needslash = 1; |
| 136 | 136 | ||
| 137 | if (*wbuf) { | 137 | if (*wbuf) { |
| 138 | if (strlen(resolved) + strlen(wbuf) + rootd + 1 > MAXPATHLEN) { | 138 | if (strlen(resolved) + strlen(wbuf) + needslash >= MAXPATHLEN) { |
| 139 | errno = ENAMETOOLONG; | 139 | errno = ENAMETOOLONG; |
| 140 | goto err1; | 140 | goto err1; |
| 141 | } | 141 | } |
| 142 | if (rootd == 0) | 142 | if (needslash) |
| 143 | strlcat(resolved, "/", MAXPATHLEN); | 143 | strlcat(resolved, "/", MAXPATHLEN); |
| 144 | strlcat(resolved, wbuf, MAXPATHLEN); | 144 | strlcat(resolved, wbuf, MAXPATHLEN); |
| 145 | } | 145 | } |
