diff options
author | 2014-10-19 03:56:28 +0000 | |
---|---|---|
committer | 2014-10-19 03:56:28 +0000 | |
commit | aa40c5fa3536dee902d055d6968a8180a4c4ba9e (patch) | |
tree | ef4e9094f45acfbfba087ce9c77009edb63af4f5 /lib/libc/stdlib/realpath.c | |
parent | Use sc_if->sk_pktlen to specify the maximum DMA transfer size and maximum (diff) | |
download | wireguard-openbsd-aa40c5fa3536dee902d055d6968a8180a4c4ba9e.tar.xz wireguard-openbsd-aa40c5fa3536dee902d055d6968a8180a4c4ba9e.zip |
Revert last commit due to changed semantics found by make release.
Diffstat (limited to 'lib/libc/stdlib/realpath.c')
-rw-r--r-- | lib/libc/stdlib/realpath.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/libc/stdlib/realpath.c b/lib/libc/stdlib/realpath.c index 8c83ec2b817..e06db59088f 100644 --- a/lib/libc/stdlib/realpath.c +++ b/lib/libc/stdlib/realpath.c @@ -1,4 +1,4 @@ -/* $OpenBSD: realpath.c,v 1.17 2014/10/18 20:43:52 doug Exp $ */ +/* $OpenBSD: realpath.c,v 1.18 2014/10/19 03:56:28 doug Exp $ */ /* * Copyright (c) 2003 Constantin S. Svintsoff <kostik@iclub.nsu.ru> * @@ -54,10 +54,6 @@ realpath(const char *path, char *resolved) int serrno, slen, mem_allocated; char left[PATH_MAX], next_token[PATH_MAX], symlink[PATH_MAX]; - if (path == NULL) { - errno = EINVAL; - return (NULL); - } if (path[0] == '\0') { errno = ENOENT; return (NULL); @@ -143,15 +139,22 @@ realpath(const char *path, char *resolved) } /* - * Append the next path component and lstat() it. + * Append the next path component and lstat() it. If + * lstat() fails we still can return successfully if + * there are no more path components left. */ resolved_len = strlcat(resolved, next_token, PATH_MAX); if (resolved_len >= PATH_MAX) { errno = ENAMETOOLONG; goto err; } - if (lstat(resolved, &sb) != 0) + if (lstat(resolved, &sb) != 0) { + if (errno == ENOENT && p == NULL) { + errno = serrno; + return (resolved); + } goto err; + } if (S_ISLNK(sb.st_mode)) { if (symlinks++ > MAXSYMLINKS) { errno = ELOOP; @@ -193,9 +196,6 @@ realpath(const char *path, char *resolved) } } left_len = strlcpy(left, symlink, sizeof(left)); - } else if (!S_ISDIR(sb.st_mode) && p != NULL) { - errno = ENOTDIR; - goto err; } } |