diff options
author | Ron Yorston <rmy@pobox.com> | 2019-03-14 09:17:12 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2019-03-14 09:19:44 +0000 |
commit | ec02b825d05d814800558995e2f28513de80206b (patch) | |
tree | 92fdc0dd7e26dd8c8f18629d783070a5458eee71 | |
parent | 1b0ac9fc815fd308057f253397723330e6fea376 (diff) | |
download | busybox-w32-ec02b825d05d814800558995e2f28513de80206b.tar.gz busybox-w32-ec02b825d05d814800558995e2f28513de80206b.tar.bz2 busybox-w32-ec02b825d05d814800558995e2f28513de80206b.zip |
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.
-rw-r--r-- | win32/mingw.c | 5 |
1 files changed, 4 insertions, 1 deletions
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) | |||
1086 | char *realpath(const char *path, char *resolved_path) | 1086 | char *realpath(const char *path, char *resolved_path) |
1087 | { | 1087 | { |
1088 | char buffer[MAX_PATH]; | 1088 | char buffer[MAX_PATH]; |
1089 | char *real_path; | 1089 | char *real_path, *p; |
1090 | 1090 | ||
1091 | /* enforce glibc pre-2.3 behaviour */ | 1091 | /* enforce glibc pre-2.3 behaviour */ |
1092 | if (path == NULL || resolved_path == NULL) { | 1092 | if (path == NULL || resolved_path == NULL) { |
@@ -1098,6 +1098,9 @@ char *realpath(const char *path, char *resolved_path) | |||
1098 | (real_path=resolve_symlinks(buffer))) { | 1098 | (real_path=resolve_symlinks(buffer))) { |
1099 | strcpy(resolved_path, real_path); | 1099 | strcpy(resolved_path, real_path); |
1100 | convert_slashes(resolved_path); | 1100 | convert_slashes(resolved_path); |
1101 | p = last_char_is(resolved_path, '/'); | ||
1102 | if (p && p > resolved_path && p[-1] != ':') | ||
1103 | *p = '\0'; | ||
1101 | return resolved_path; | 1104 | return resolved_path; |
1102 | } | 1105 | } |
1103 | return NULL; | 1106 | return NULL; |