From c4cc5784faad0655d2fe9e462105f2ea142d3363 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Fri, 7 Dec 2018 12:47:39 +0000 Subject: 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'. --- win32/mingw.c | 5 +++-- 1 file 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" }; static int has_win_suffix(const char *name, int start) { - int i, len = strlen(name); + const char *bname = bb_basename(name); + int i, len = strlen(bname); if (len > 4 && name[len-4] == '.') { for (i=start; i<4; ++i) { - if (!strcasecmp(name+len-3, win_suffix[i])) { + if (!strcasecmp(bname+len-3, win_suffix[i])) { return 1; } } -- cgit v1.2.3-55-g6feb