From c2c480719f91c3ccd477cf0360e78509eb8530df Mon Sep 17 00:00:00 2001 From: Nguyễn Thái Ngọc Duy Date: Fri, 17 Sep 2010 10:39:33 +1000 Subject: win32: lowercase argv[0] before searching for applet name On Windows, busybox.exe can be called BusyBox.exe, BUSYBOX.EXE... Applet search is done using bsearch(), doing case-insensitive search would be more difficult. So just lowercase everything down. BUSYBOX_APPLET_NAME environment variable are supposed to be case-sensitive though. --- libbb/appletlib.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'libbb') diff --git a/libbb/appletlib.c b/libbb/appletlib.c index 6a304ded3..ab1d48c31 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c @@ -827,9 +827,13 @@ int main(int argc UNUSED_PARAM, char **argv) unsetenv("BUSYBOX_APPLET_NAME"); } else { - int len = strlen(applet_name); - if (len > 4 && !strcmp(applet_name+len-4, ".exe")) - argv[0][applet_name-argv[0]+len-4] = '\0'; + int i, len = strlen(applet_name); + if (len > 4 && !strcmp(applet_name+len-4, ".exe")) { + len -= 4; + argv[0][applet_name-argv[0]+len] = '\0'; + } + for (i = 0; i < len; i++) + argv[0][applet_name-argv[0]+i] = tolower(applet_name[i]); } } applet_name = bb_basename(applet_name); -- cgit v1.2.3-55-g6feb