From 401da56c0ffd3d7f4bcfbee6574a3cfb6d921a0b Mon Sep 17 00:00:00 2001 From: Max Khon Date: Mon, 2 Jun 2003 13:31:16 +0000 Subject: MFC: rev. 1.20: fix stripping last path component when only one path component left. PR: 52686 --- lib/libc/stdlib/realpath.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/libc/stdlib') diff --git a/lib/libc/stdlib/realpath.c b/lib/libc/stdlib/realpath.c index 9dbb9b9269dd..8313a2749791 100644 --- a/lib/libc/stdlib/realpath.c +++ b/lib/libc/stdlib/realpath.c @@ -117,7 +117,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; } @@ -156,7 +156,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; } -- cgit v1.3