From ec02b825d05d814800558995e2f28513de80206b Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Thu, 14 Mar 2019 09:17:12 +0000 Subject: win32: realpath(3): remove trailing slash If the path is that of a drive mapped to a network share _fullpath() leaves the trailing slash on the drive name and it remains present after the call to resolve_symlinks(). Remove a trailing slash from the resolved path unless it's preceded by a colon. --- win32/mingw.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'win32') diff --git a/win32/mingw.c b/win32/mingw.c index c04cc4872..3788e8a06 100644 --- a/win32/mingw.c +++ b/win32/mingw.c @@ -1086,7 +1086,7 @@ static char *resolve_symlinks(char *path) char *realpath(const char *path, char *resolved_path) { char buffer[MAX_PATH]; - char *real_path; + char *real_path, *p; /* enforce glibc pre-2.3 behaviour */ if (path == NULL || resolved_path == NULL) { @@ -1098,6 +1098,9 @@ char *realpath(const char *path, char *resolved_path) (real_path=resolve_symlinks(buffer))) { strcpy(resolved_path, real_path); convert_slashes(resolved_path); + p = last_char_is(resolved_path, '/'); + if (p && p > resolved_path && p[-1] != ':') + *p = '\0'; return resolved_path; } return NULL; -- cgit v1.2.3-55-g6feb