aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2018-02-28 16:48:33 +0000
committerRon Yorston <rmy@pobox.com>2018-02-28 16:48:33 +0000
commitb0a565de930df8dc4fd8f00cbfe3a585391cb05a (patch)
tree4098345cacecbe4e8f5e6dc72810e61101072ccc
parentdecda04ffdbe4803e3d346b3784403b68faba82e (diff)
downloadbusybox-w32-b0a565de930df8dc4fd8f00cbfe3a585391cb05a.tar.gz
busybox-w32-b0a565de930df8dc4fd8f00cbfe3a585391cb05a.tar.bz2
busybox-w32-b0a565de930df8dc4fd8f00cbfe3a585391cb05a.zip
win32: don't add extensions to filenames ending with a dot
A filename ending with a dot is a signal to spawnve not to try adding extensions but to use the name unmodified. The add_win32_extension function should follow the same rule.
-rw-r--r--include/mingw.h3
-rw-r--r--win32/mingw.c8
2 files changed, 9 insertions, 2 deletions
diff --git a/include/mingw.h b/include/mingw.h
index c116e551a..b0e1fa53c 100644
--- a/include/mingw.h
+++ b/include/mingw.h
@@ -474,8 +474,9 @@ char **env_setenv(char **env, const char *name);
474const char *get_busybox_exec_path(void); 474const char *get_busybox_exec_path(void);
475void init_winsock(void); 475void init_winsock(void);
476 476
477int has_exe_suffix(const char *p);
478int has_bat_suffix(const char *p); 477int has_bat_suffix(const char *p);
478int has_exe_suffix(const char *p);
479int has_exe_suffix_or_dot(const char *name);
479char *add_win32_extension(const char *p); 480char *add_win32_extension(const char *p);
480int has_exec_format(const char *name); 481int has_exec_format(const char *name);
481 482
diff --git a/win32/mingw.c b/win32/mingw.c
index 22e62232d..260bc82d7 100644
--- a/win32/mingw.c
+++ b/win32/mingw.c
@@ -1033,6 +1033,12 @@ int has_exe_suffix(const char *name)
1033 return has_win_suffix(name, 0); 1033 return has_win_suffix(name, 0);
1034} 1034}
1035 1035
1036int has_exe_suffix_or_dot(const char *name)
1037{
1038 int len = strlen(name);
1039 return (len > 0 && name[len-1] == '.') || has_win_suffix(name, 0);
1040}
1041
1036/* check if path can be made into an executable by adding a suffix; 1042/* check if path can be made into an executable by adding a suffix;
1037 * return an allocated string containing the path if it can; 1043 * return an allocated string containing the path if it can;
1038 * return NULL if not. 1044 * return NULL if not.
@@ -1044,7 +1050,7 @@ char *add_win32_extension(const char *p)
1044 char *path; 1050 char *path;
1045 int i, len; 1051 int i, len;
1046 1052
1047 if (has_exe_suffix(p)) { 1053 if (has_exe_suffix_or_dot(p)) {
1048 return NULL; 1054 return NULL;
1049 } 1055 }
1050 1056