mirror of
https://github.com/PowerShell/openssh-portable.git
synced 2025-07-27 15:54:22 +02:00
upstream commit
revision 1.18 date: 2014/10/19 03:56:28; author: doug; state: Exp; lines: +9 -9; commitid: U6QxmtbXrGoc02S5; Revert last commit due to changed semantics found by make release.
This commit is contained in:
parent
c39ad23b06
commit
c71be375a6
@ -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>
|
* Copyright (c) 2003 Constantin S. Svintsoff <kostik@iclub.nsu.ru>
|
||||||
*
|
*
|
||||||
@ -62,10 +62,6 @@ realpath(const char *path, char *resolved)
|
|||||||
int serrno, slen, mem_allocated;
|
int serrno, slen, mem_allocated;
|
||||||
char left[PATH_MAX], next_token[PATH_MAX], symlink[PATH_MAX];
|
char left[PATH_MAX], next_token[PATH_MAX], symlink[PATH_MAX];
|
||||||
|
|
||||||
if (path == NULL) {
|
|
||||||
errno = EINVAL;
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
if (path[0] == '\0') {
|
if (path[0] == '\0') {
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
return (NULL);
|
return (NULL);
|
||||||
@ -151,15 +147,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);
|
resolved_len = strlcat(resolved, next_token, PATH_MAX);
|
||||||
if (resolved_len >= PATH_MAX) {
|
if (resolved_len >= PATH_MAX) {
|
||||||
errno = ENAMETOOLONG;
|
errno = ENAMETOOLONG;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
if (lstat(resolved, &sb) != 0)
|
if (lstat(resolved, &sb) != 0) {
|
||||||
|
if (errno == ENOENT && p == NULL) {
|
||||||
|
errno = serrno;
|
||||||
|
return (resolved);
|
||||||
|
}
|
||||||
goto err;
|
goto err;
|
||||||
|
}
|
||||||
if (S_ISLNK(sb.st_mode)) {
|
if (S_ISLNK(sb.st_mode)) {
|
||||||
if (symlinks++ > MAXSYMLINKS) {
|
if (symlinks++ > MAXSYMLINKS) {
|
||||||
errno = ELOOP;
|
errno = ELOOP;
|
||||||
@ -202,9 +205,6 @@ realpath(const char *path, char *resolved)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
left_len = strlcpy(left, symlink, sizeof(left));
|
left_len = strlcpy(left, symlink, sizeof(left));
|
||||||
} else if (!S_ISDIR(sb.st_mode) && p != NULL) {
|
|
||||||
errno = ENOTDIR;
|
|
||||||
goto err;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user