diff options
author | Ron Yorston <rmy@pobox.com> | 2018-12-07 12:47:39 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2018-12-07 12:47:39 +0000 |
commit | c4cc5784faad0655d2fe9e462105f2ea142d3363 (patch) | |
tree | 9140825f6c00f61d1eae77cae7b577749d472bfa | |
parent | 1fe3f5449a4a3ea6fc8460df40d95d118ed5d4ee (diff) | |
download | busybox-w32-c4cc5784faad0655d2fe9e462105f2ea142d3363.tar.gz busybox-w32-c4cc5784faad0655d2fe9e462105f2ea142d3363.tar.bz2 busybox-w32-c4cc5784faad0655d2fe9e462105f2ea142d3363.zip |
win32: fix to file extension test
When looking for the special WIN32 file extensions only consider the
file's basename, not the full path. Otherwise a file called '.bat',
for example, is considered executable by 'ls -a' and the shell tries
to run './.bat'.
-rw-r--r-- | win32/mingw.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/win32/mingw.c b/win32/mingw.c index 08d955527..3398e3df4 100644 --- a/win32/mingw.c +++ b/win32/mingw.c | |||
@@ -1164,11 +1164,12 @@ static const char win_suffix[4][4] = { "com", "exe", "bat", "cmd" }; | |||
1164 | 1164 | ||
1165 | static int has_win_suffix(const char *name, int start) | 1165 | static int has_win_suffix(const char *name, int start) |
1166 | { | 1166 | { |
1167 | int i, len = strlen(name); | 1167 | const char *bname = bb_basename(name); |
1168 | int i, len = strlen(bname); | ||
1168 | 1169 | ||
1169 | if (len > 4 && name[len-4] == '.') { | 1170 | if (len > 4 && name[len-4] == '.') { |
1170 | for (i=start; i<4; ++i) { | 1171 | for (i=start; i<4; ++i) { |
1171 | if (!strcasecmp(name+len-3, win_suffix[i])) { | 1172 | if (!strcasecmp(bname+len-3, win_suffix[i])) { |
1172 | return 1; | 1173 | return 1; |
1173 | } | 1174 | } |
1174 | } | 1175 | } |