diff options
-rw-r--r-- | include/mingw.h | 1 | ||||
-rw-r--r-- | libbb/appletlib.c | 6 | ||||
-rw-r--r-- | networking/httpd.c | 7 | ||||
-rw-r--r-- | shell/ash.c | 2 | ||||
-rw-r--r-- | win32/mingw.c | 41 |
5 files changed, 22 insertions, 35 deletions
diff --git a/include/mingw.h b/include/mingw.h index 93fad0605..b0342337d 100644 --- a/include/mingw.h +++ b/include/mingw.h | |||
@@ -622,7 +622,6 @@ int enumerate_links(const char *file, char *name); | |||
622 | int unc_root_len(const char *dir); | 622 | int unc_root_len(const char *dir); |
623 | int root_len(const char *path); | 623 | int root_len(const char *path); |
624 | const char *get_system_drive(void); | 624 | const char *get_system_drive(void); |
625 | const char *need_system_drive(const char *path); | ||
626 | int chdir_system_drive(void); | 625 | int chdir_system_drive(void); |
627 | char *xabsolute_path(char *path); | 626 | char *xabsolute_path(char *path); |
628 | char *get_drive_cwd(const char *path, char *buffer, int size); | 627 | char *get_drive_cwd(const char *path, char *buffer, int size); |
diff --git a/libbb/appletlib.c b/libbb/appletlib.c index 54be59f2d..97dfb3df8 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c | |||
@@ -781,7 +781,7 @@ static void install_links(const char *busybox, int use_symbolic_links, | |||
781 | unsigned i; | 781 | unsigned i; |
782 | int rc; | 782 | int rc; |
783 | # if ENABLE_PLATFORM_MINGW32 | 783 | # if ENABLE_PLATFORM_MINGW32 |
784 | const char *sd = NULL; | 784 | const char *sd = ""; |
785 | 785 | ||
786 | if (custom_install_dir != NULL) { | 786 | if (custom_install_dir != NULL) { |
787 | bb_make_directory(custom_install_dir, 0755, FILEUTILS_RECUR); | 787 | bb_make_directory(custom_install_dir, 0755, FILEUTILS_RECUR); |
@@ -789,7 +789,7 @@ static void install_links(const char *busybox, int use_symbolic_links, | |||
789 | else { | 789 | else { |
790 | sd = get_system_drive(); | 790 | sd = get_system_drive(); |
791 | for (i=1; i<ARRAY_SIZE(install_dir); ++i) { | 791 | for (i=1; i<ARRAY_SIZE(install_dir); ++i) { |
792 | fpc = xasprintf("%s%s", sd ?: "", install_dir[i]); | 792 | fpc = concat_path_file(sd, install_dir[i]); |
793 | bb_make_directory(fpc, 0755, FILEUTILS_RECUR); | 793 | bb_make_directory(fpc, 0755, FILEUTILS_RECUR); |
794 | free(fpc); | 794 | free(fpc); |
795 | } | 795 | } |
@@ -802,7 +802,7 @@ static void install_links(const char *busybox, int use_symbolic_links, | |||
802 | 802 | ||
803 | for (i = 0; i < ARRAY_SIZE(applet_main); i++) { | 803 | for (i = 0; i < ARRAY_SIZE(applet_main); i++) { |
804 | # if ENABLE_PLATFORM_MINGW32 | 804 | # if ENABLE_PLATFORM_MINGW32 |
805 | fpc = xasprintf("%s%s/%s.exe", sd ?: "", | 805 | fpc = xasprintf("%s%s/%s.exe", sd, |
806 | custom_install_dir ?: install_dir[APPLET_INSTALL_LOC(i)], | 806 | custom_install_dir ?: install_dir[APPLET_INSTALL_LOC(i)], |
807 | appname); | 807 | appname); |
808 | # else | 808 | # else |
diff --git a/networking/httpd.c b/networking/httpd.c index bd3a5a097..1dae602ee 100644 --- a/networking/httpd.c +++ b/networking/httpd.c | |||
@@ -754,10 +754,11 @@ static int parse_conf(const char *path, int flag) | |||
754 | filename = alloca(strlen(path) + sizeof(HTTPD_CONF) + 2); | 754 | filename = alloca(strlen(path) + sizeof(HTTPD_CONF) + 2); |
755 | sprintf((char *)filename, "%s/%s", path, HTTPD_CONF); | 755 | sprintf((char *)filename, "%s/%s", path, HTTPD_CONF); |
756 | #else | 756 | #else |
757 | const char *sd = need_system_drive(path); | 757 | const char *sd = ""; |
758 | if (root_len(path) == 0 && (path[0] == '/' || path[0] == '\\')) | ||
759 | sd = get_system_drive(); | ||
758 | 760 | ||
759 | filename = auto_string(xasprintf("%s%s/%s", sd ? sd : "", | 761 | filename = auto_string(xasprintf("%s%s/%s", sd, path, HTTPD_CONF)); |
760 | path, HTTPD_CONF)); | ||
761 | #endif | 762 | #endif |
762 | } | 763 | } |
763 | 764 | ||
diff --git a/shell/ash.c b/shell/ash.c index e2dcb0962..881bc12ab 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -16292,7 +16292,7 @@ int ash_main(int argc UNUSED_PARAM, char **argv) | |||
16292 | 16292 | ||
16293 | state = 1; | 16293 | state = 1; |
16294 | #if ENABLE_PLATFORM_MINGW32 | 16294 | #if ENABLE_PLATFORM_MINGW32 |
16295 | hp = xasprintf("%s/etc/profile", get_system_drive() ?: ""); | 16295 | hp = concat_path_file(get_system_drive(), "/etc/profile"); |
16296 | read_profile(hp); | 16296 | read_profile(hp); |
16297 | free((void *)hp); | 16297 | free((void *)hp); |
16298 | #else | 16298 | #else |
diff --git a/win32/mingw.c b/win32/mingw.c index 7e42e4434..6544d11ad 100644 --- a/win32/mingw.c +++ b/win32/mingw.c | |||
@@ -1146,17 +1146,6 @@ static char *gethomedir(void) | |||
1146 | return buf; | 1146 | return buf; |
1147 | } | 1147 | } |
1148 | 1148 | ||
1149 | static char *getsysdir(void) | ||
1150 | { | ||
1151 | static char *buf = NULL; | ||
1152 | |||
1153 | if (!buf) { | ||
1154 | buf = xzalloc(PATH_MAX); | ||
1155 | GetSystemDirectory(buf, PATH_MAX); | ||
1156 | } | ||
1157 | return buf; | ||
1158 | } | ||
1159 | |||
1160 | #define NAME_LEN 100 | 1149 | #define NAME_LEN 100 |
1161 | char *get_user_name(void) | 1150 | char *get_user_name(void) |
1162 | { | 1151 | { |
@@ -2297,27 +2286,21 @@ int root_len(const char *path) | |||
2297 | 2286 | ||
2298 | const char *get_system_drive(void) | 2287 | const char *get_system_drive(void) |
2299 | { | 2288 | { |
2300 | static char *drive = NULL; | 2289 | static const char *drive = NULL; |
2290 | char sysdir[PATH_MAX]; | ||
2301 | int len; | 2291 | int len; |
2302 | 2292 | ||
2303 | if (drive == NULL) { | 2293 | if (drive == NULL) { |
2304 | const char *sysdir = getsysdir(); | 2294 | UINT ret = GetSystemDirectory(sysdir, PATH_MAX); |
2305 | if ((len=root_len(sysdir))) { | 2295 | if ((ret != 0 && ret < PATH_MAX) && (len=root_len(sysdir))) |
2306 | drive = xstrndup(sysdir, len); | 2296 | drive = xstrndup(sysdir, len); |
2307 | } | 2297 | else |
2298 | drive = ""; | ||
2308 | } | 2299 | } |
2309 | 2300 | ||
2310 | return getenv(BB_SYSTEMROOT) ?: drive; | 2301 | return getenv(BB_SYSTEMROOT) ?: drive; |
2311 | } | 2302 | } |
2312 | 2303 | ||
2313 | /* Return pointer to system drive if path is of form '/file', else NULL */ | ||
2314 | const char *need_system_drive(const char *path) | ||
2315 | { | ||
2316 | if (root_len(path) == 0 && (path[0] == '/' || path[0] == '\\')) | ||
2317 | return get_system_drive(); | ||
2318 | return NULL; | ||
2319 | } | ||
2320 | |||
2321 | int chdir_system_drive(void) | 2304 | int chdir_system_drive(void) |
2322 | { | 2305 | { |
2323 | const char *sd = get_system_drive(); | 2306 | const char *sd = get_system_drive(); |
@@ -2409,10 +2392,14 @@ void *get_proc_addr(const char *dll, const char *function, | |||
2409 | * on Windows 7. If it does, retry using LoadLibrary with an | 2392 | * on Windows 7. If it does, retry using LoadLibrary with an |
2410 | * explicit, backslash-separated path. */ | 2393 | * explicit, backslash-separated path. */ |
2411 | if (!hnd) { | 2394 | if (!hnd) { |
2412 | char *path = concat_path_file(getsysdir(), dll); | 2395 | char buf[PATH_MAX]; |
2413 | slash_to_bs(path); | 2396 | UINT ret = GetSystemDirectory(buf, PATH_MAX); |
2414 | hnd = LoadLibrary(path); | 2397 | if (ret != 0 && ret < PATH_MAX) { |
2415 | free(path); | 2398 | char *path = concat_path_file(buf, dll); |
2399 | slash_to_bs(path); | ||
2400 | hnd = LoadLibrary(path); | ||
2401 | free(path); | ||
2402 | } | ||
2416 | } | 2403 | } |
2417 | 2404 | ||
2418 | if (hnd) | 2405 | if (hnd) |