From f9569be1e5ca929d68e28064be3ffadcb0aff784 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Wed, 18 Mar 2020 10:48:44 +0000 Subject: win32: improve handling of 'c:file' paths for executables bb_basename() didn't properly handle paths of the form 'c:file'. Attempting to run 'c:busybox' resulted in 'c:busybox: applet not found'. The shell had a similar problem: trying to run 'c:busybox' reported 'sh: c:busybox: not found'. --- libbb/get_last_path_component.c | 2 +- shell/ash.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/libbb/get_last_path_component.c b/libbb/get_last_path_component.c index 3a9b9237e..00649620d 100644 --- a/libbb/get_last_path_component.c +++ b/libbb/get_last_path_component.c @@ -13,7 +13,7 @@ const char* FAST_FUNC bb_basename(const char *name) #if ENABLE_PLATFORM_MINGW32 const char *cp; for (cp = name; *cp; cp++) - if (*cp == '/' || *cp == '\\') + if (*cp == '/' || *cp == '\\' || *cp == ':') name = cp + 1; #else const char *cp = strrchr(name, '/'); diff --git a/shell/ash.c b/shell/ash.c index 47ad85440..6a03ef6b4 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -8729,7 +8729,11 @@ static void shellexec(char *prog, char **argv, const char *path, int idx) int applet_no = -1; /* used only by FEATURE_SH_STANDALONE */ envp = listvars(VEXPORT, VUNSET, /*strlist:*/ NULL, /*end:*/ NULL); - if ((strchr(prog, '/') || (ENABLE_PLATFORM_MINGW32 && strchr(prog, '\\'))) +#if ENABLE_PLATFORM_MINGW32 + if ((strchr(prog, '/') || strchr(prog, '\\') || has_dos_drive_prefix(prog)) +#else + if (strchr(prog, '/') != NULL +#endif #if ENABLE_FEATURE_SH_STANDALONE || (applet_no = find_applet_by_name(prog)) >= 0 #endif @@ -14235,7 +14239,11 @@ find_command(char *name, struct cmdentry *entry, int act, const char *path) int len; /* If name contains a slash, don't use PATH or hash table */ - if (strchr(name, '/') || (ENABLE_PLATFORM_MINGW32 && strchr(name, '\\'))) { +#if ENABLE_PLATFORM_MINGW32 + if (strchr(name, '/') || strchr(name, '\\') || has_dos_drive_prefix(name)) { +#else + if (strchr(name, '/' != NULL) { +#endif entry->u.index = -1; if (act & DO_ABS) { #if ENABLE_PLATFORM_MINGW32 -- cgit v1.2.3-55-g6feb