summaryrefslogtreecommitdiff
path: root/openbsd-compat/realpath.c
diff options
context:
space:
mode:
Diffstat (limited to 'openbsd-compat/realpath.c')
-rw-r--r--openbsd-compat/realpath.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/openbsd-compat/realpath.c b/openbsd-compat/realpath.c
index 4286bde72..77da14e7c 100644
--- a/openbsd-compat/realpath.c
+++ b/openbsd-compat/realpath.c
@@ -35,7 +35,7 @@
35#if !defined(HAVE_REALPATH) || defined(BROKEN_REALPATH) 35#if !defined(HAVE_REALPATH) || defined(BROKEN_REALPATH)
36 36
37#if defined(LIBC_SCCS) && !defined(lint) 37#if defined(LIBC_SCCS) && !defined(lint)
38static char *rcsid = "$OpenBSD: realpath.c,v 1.9 2003/06/02 20:18:38 millert Exp $"; 38static char *rcsid = "$OpenBSD: realpath.c,v 1.10 2003/08/01 21:04:59 millert Exp $";
39#endif /* LIBC_SCCS and not lint */ 39#endif /* LIBC_SCCS and not lint */
40 40
41#include <sys/param.h> 41#include <sys/param.h>
@@ -65,7 +65,7 @@ char *
65realpath(const char *path, char *resolved) 65realpath(const char *path, char *resolved)
66{ 66{
67 struct stat sb; 67 struct stat sb;
68 int fd, n, rootd, serrno = 0; 68 int fd, n, needslash, serrno = 0;
69 char *p, *q, wbuf[MAXPATHLEN], start[MAXPATHLEN]; 69 char *p, *q, wbuf[MAXPATHLEN], start[MAXPATHLEN];
70 int symlinks = 0; 70 int symlinks = 0;
71 71
@@ -141,16 +141,16 @@ loop:
141 * happens if the last component is empty, or the dirname is root. 141 * happens if the last component is empty, or the dirname is root.
142 */ 142 */
143 if (resolved[0] == '/' && resolved[1] == '\0') 143 if (resolved[0] == '/' && resolved[1] == '\0')
144 rootd = 1; 144 needslash = 0;
145 else 145 else
146 rootd = 0; 146 needslash = 1;
147 147
148 if (*wbuf) { 148 if (*wbuf) {
149 if (strlen(resolved) + strlen(wbuf) + rootd + 1 > MAXPATHLEN) { 149 if (strlen(resolved) + strlen(wbuf) + needslash >= MAXPATHLEN) {
150 serrno = ENAMETOOLONG; 150 serrno = ENAMETOOLONG;
151 goto err1; 151 goto err1;
152 } 152 }
153 if (rootd == 0) 153 if (needslash == 0)
154 strlcat(resolved, "/", MAXPATHLEN); 154 strlcat(resolved, "/", MAXPATHLEN);
155 strlcat(resolved, wbuf, MAXPATHLEN); 155 strlcat(resolved, wbuf, MAXPATHLEN);
156 } 156 }