aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2020-03-18 10:48:44 +0000
committerRon Yorston <rmy@pobox.com>2020-03-18 11:27:05 +0000
commitf9569be1e5ca929d68e28064be3ffadcb0aff784 (patch)
treede93d003e3baf86ec28d6d3f37098f619a99e1ff
parent5e69872105e69980e5feb0b071a442cd423c59f5 (diff)
downloadbusybox-w32-f9569be1e5ca929d68e28064be3ffadcb0aff784.tar.gz
busybox-w32-f9569be1e5ca929d68e28064be3ffadcb0aff784.tar.bz2
busybox-w32-f9569be1e5ca929d68e28064be3ffadcb0aff784.zip
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'.
-rw-r--r--libbb/get_last_path_component.c2
-rw-r--r--shell/ash.c12
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)
13#if ENABLE_PLATFORM_MINGW32 13#if ENABLE_PLATFORM_MINGW32
14 const char *cp; 14 const char *cp;
15 for (cp = name; *cp; cp++) 15 for (cp = name; *cp; cp++)
16 if (*cp == '/' || *cp == '\\') 16 if (*cp == '/' || *cp == '\\' || *cp == ':')
17 name = cp + 1; 17 name = cp + 1;
18#else 18#else
19 const char *cp = strrchr(name, '/'); 19 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)
8729 int applet_no = -1; /* used only by FEATURE_SH_STANDALONE */ 8729 int applet_no = -1; /* used only by FEATURE_SH_STANDALONE */
8730 8730
8731 envp = listvars(VEXPORT, VUNSET, /*strlist:*/ NULL, /*end:*/ NULL); 8731 envp = listvars(VEXPORT, VUNSET, /*strlist:*/ NULL, /*end:*/ NULL);
8732 if ((strchr(prog, '/') || (ENABLE_PLATFORM_MINGW32 && strchr(prog, '\\'))) 8732#if ENABLE_PLATFORM_MINGW32
8733 if ((strchr(prog, '/') || strchr(prog, '\\') || has_dos_drive_prefix(prog))
8734#else
8735 if (strchr(prog, '/') != NULL
8736#endif
8733#if ENABLE_FEATURE_SH_STANDALONE 8737#if ENABLE_FEATURE_SH_STANDALONE
8734 || (applet_no = find_applet_by_name(prog)) >= 0 8738 || (applet_no = find_applet_by_name(prog)) >= 0
8735#endif 8739#endif
@@ -14235,7 +14239,11 @@ find_command(char *name, struct cmdentry *entry, int act, const char *path)
14235 int len; 14239 int len;
14236 14240
14237 /* If name contains a slash, don't use PATH or hash table */ 14241 /* If name contains a slash, don't use PATH or hash table */
14238 if (strchr(name, '/') || (ENABLE_PLATFORM_MINGW32 && strchr(name, '\\'))) { 14242#if ENABLE_PLATFORM_MINGW32
14243 if (strchr(name, '/') || strchr(name, '\\') || has_dos_drive_prefix(name)) {
14244#else
14245 if (strchr(name, '/' != NULL) {
14246#endif
14239 entry->u.index = -1; 14247 entry->u.index = -1;
14240 if (act & DO_ABS) { 14248 if (act & DO_ABS) {
14241#if ENABLE_PLATFORM_MINGW32 14249#if ENABLE_PLATFORM_MINGW32