summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorfjoe <fjoe@FreeBSD.org>2003-05-28 08:23:01 +0000
committerfjoe <fjoe@FreeBSD.org>2003-05-28 08:23:01 +0000
commit31071c76d075fbf1bace9dcd55b26d610a7aa234 (patch)
tree4086c738a8a4678ed1fdbbca3f8d6ab4bb5c64cd /lib
parent12178a6e04f2bbfbb89740b5e76d20ba1855e157 (diff)
downloadFreeBSD-src-31071c76d075fbf1bace9dcd55b26d610a7aa234.zip
FreeBSD-src-31071c76d075fbf1bace9dcd55b26d610a7aa234.tar.gz
Fix stripping last path component when only one path component left.
PR: 52686 MFC after: 1 day
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/stdlib/realpath.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libc/stdlib/realpath.c b/lib/libc/stdlib/realpath.c
index c269471..3082f5f 100644
--- a/lib/libc/stdlib/realpath.c
+++ b/lib/libc/stdlib/realpath.c
@@ -119,7 +119,7 @@ realpath(const char *path, char resolved[PATH_MAX])
*/
if (resolved_len > 1) {
resolved[resolved_len - 1] = '\0';
- q = strrchr(resolved, '/');
+ q = strrchr(resolved, '/') + 1;
*q = '\0';
resolved_len = q - resolved;
}
@@ -158,7 +158,7 @@ realpath(const char *path, char resolved[PATH_MAX])
} else if (resolved_len > 1) {
/* Strip the last path component. */
resolved[resolved_len - 1] = '\0';
- q = strrchr(resolved, '/');
+ q = strrchr(resolved, '/') + 1;
*q = '\0';
resolved_len = q - resolved;
}
OpenPOWER on IntegriCloud