Browse Source

The last consumer of pre-posix realpath behaviour has stopped

requiring it (sftp-server).
Remove the /exists///// behaviour from here.  The /nonexistant
behaviour remains in the kernel and needs to be shot next.
There may be ports fallout, but we doubt it.
ok beck djm
OPENBSD_6_6
deraadt 5 years ago
parent
commit
e4c1e3b43b
1 changed files with 3 additions and 34 deletions
  1. +3
    -34
      src/lib/libc/stdlib/realpath.c

+ 3
- 34
src/lib/libc/stdlib/realpath.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: realpath.c,v 1.26 2019/06/17 03:13:17 deraadt Exp $ */
/* $OpenBSD: realpath.c,v 1.27 2019/07/05 05:04:26 deraadt Exp $ */
/* /*
* Copyright (c) 2019 Bob Beck <beck@openbsd.org> * Copyright (c) 2019 Bob Beck <beck@openbsd.org>
* Copyright (c) 2019 Theo de Raadt <deraadt@openbsd.org> * Copyright (c) 2019 Theo de Raadt <deraadt@openbsd.org>
@ -36,39 +36,8 @@ realpath(const char *path, char *resolved)
{ {
char rbuf[PATH_MAX]; char rbuf[PATH_MAX];
if (__realpath(path, rbuf) == -1) {
/*
* XXX XXX XXX
*
* The old userland implementation strips trailing slashes.
* According to Dr. POSIX, realpathing "/bsd" should be fine,
* realpathing "/bsd/" should return ENOTDIR.
*
* Similar, but *different* to the above, The old userland
* implementation allows for realpathing "/nonexistent" but
* not "/nonexistent/", Both those should return ENOENT
* according to POSIX.
*
* This hack should go away once we decide to match POSIX.
* which we should as soon as is convenient.
*/
if (errno == ENOTDIR) {
char pbuf[PATH_MAX];
ssize_t i;
if (strlcpy(pbuf, path, sizeof(pbuf)) >= sizeof(pbuf)) {
errno = ENAMETOOLONG;
return NULL;
}
/* Try again without the trailing slashes. */
for (i = strlen(pbuf); i > 1 && pbuf[i - 1] == '/'; i--)
pbuf[i - 1] = '\0';
if (__realpath(pbuf, rbuf) == -1)
return NULL;
} else
return NULL;
}
if (__realpath(path, rbuf) == -1)
return NULL;
if (resolved == NULL) if (resolved == NULL)
return (strdup(rbuf)); return (strdup(rbuf));
strlcpy(resolved, rbuf, PATH_MAX); strlcpy(resolved, rbuf, PATH_MAX);


Loading…
Cancel
Save