diff options
Diffstat (limited to 'src/lib/libc/stdlib')
| -rw-r--r-- | src/lib/libc/stdlib/realpath.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/lib/libc/stdlib/realpath.c b/src/lib/libc/stdlib/realpath.c index a6195c1dcb..061f1a7ef1 100644 --- a/src/lib/libc/stdlib/realpath.c +++ b/src/lib/libc/stdlib/realpath.c | |||
| @@ -35,7 +35,7 @@ | |||
| 35 | */ | 35 | */ |
| 36 | 36 | ||
| 37 | #if defined(LIBC_SCCS) && !defined(lint) | 37 | #if defined(LIBC_SCCS) && !defined(lint) |
| 38 | static char *rcsid = "$OpenBSD: realpath.c,v 1.5 2001/06/27 00:58:56 lebel Exp $"; | 38 | static char *rcsid = "$OpenBSD: realpath.c,v 1.6 2002/01/12 16:24:35 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> |
| @@ -70,6 +70,10 @@ realpath(path, resolved) | |||
| 70 | return (NULL); | 70 | return (NULL); |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | /* Convert "." -> "" to optimize away a needless lstat() and chdir() */ | ||
| 74 | if (path[0] == '.' && path[1] == '\0') | ||
| 75 | path = ""; | ||
| 76 | |||
| 73 | /* | 77 | /* |
| 74 | * Find the dirname and basename from the path to be resolved. | 78 | * Find the dirname and basename from the path to be resolved. |
| 75 | * Change directory to the dirname component. | 79 | * Change directory to the dirname component. |
| @@ -98,7 +102,7 @@ loop: | |||
| 98 | p = resolved; | 102 | p = resolved; |
| 99 | 103 | ||
| 100 | /* Deal with the last component. */ | 104 | /* Deal with the last component. */ |
| 101 | if (lstat(p, &sb) == 0) { | 105 | if (*p != '\0' && lstat(p, &sb) == 0) { |
| 102 | if (S_ISLNK(sb.st_mode)) { | 106 | if (S_ISLNK(sb.st_mode)) { |
| 103 | if (++symlinks > MAXSYMLINKS) { | 107 | if (++symlinks > MAXSYMLINKS) { |
| 104 | errno = ELOOP; | 108 | errno = ELOOP; |
