From b5cd41cdf4e6afd475fe34b755f99578e20b08ca Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Mon, 1 Mar 2021 09:37:50 +0000 Subject: libbb: fix detection of relative paths in xreadlink.c In xmalloc_follow_symlinks() the code to detect relative paths needs to be altered for WIN32. We don't want C:/path to be treated as a relative path. --- libbb/xreadlink.c | 4 ++++ win32/mingw.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libbb/xreadlink.c b/libbb/xreadlink.c index ca53e12d3..f0a63fd9b 100644 --- a/libbb/xreadlink.c +++ b/libbb/xreadlink.c @@ -76,7 +76,11 @@ char* FAST_FUNC xmalloc_follow_symlinks(const char *path) return NULL; } +#if ENABLE_PLATFORM_MINGW32 + if (!is_absolute_path(linkpath)) { +#else if (*linkpath != '/') { +#endif bufsize += strlen(linkpath); buf = xrealloc(buf, bufsize); lpc = bb_get_last_path_component_strip(buf); diff --git a/win32/mingw.c b/win32/mingw.c index a222e6226..1a00787b7 100644 --- a/win32/mingw.c +++ b/win32/mingw.c @@ -843,7 +843,7 @@ int mingw_rename(const char *pold, const char *pnew) return -1; } if (MoveFileEx(pold, pnew, - MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED)) + MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED)) return 0; /* TODO: translate more errors */ if (GetLastError() == ERROR_ACCESS_DENIED && -- cgit v1.2.3-55-g6feb