diff options
author | Eric Andersen <andersen@codepoet.org> | 2001-05-11 16:58:46 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2001-05-11 16:58:46 +0000 |
commit | 5f265b755a92e7efdbd0d18694913209dfd9e055 (patch) | |
tree | e6644e9f97dab0198ad771e1d330e02a7cce8553 /shell/hush.c | |
parent | 9d94deabd398634c6d1c601ba276f5afd97b2050 (diff) | |
download | busybox-w32-5f265b755a92e7efdbd0d18694913209dfd9e055.tar.gz busybox-w32-5f265b755a92e7efdbd0d18694913209dfd9e055.tar.bz2 busybox-w32-5f265b755a92e7efdbd0d18694913209dfd9e055.zip |
Fix a segfault in lash, hush, and cmdedit. Each of these used
xgetcwd, but did not check the return for a NULL, and then continued
to call strlen on the NULL when the cwd had been removed from under it.
-Erik
Diffstat (limited to 'shell/hush.c')
-rw-r--r-- | shell/hush.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/shell/hush.c b/shell/hush.c index abc8f6e60..9a2243a89 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -429,6 +429,8 @@ static int builtin_cd(struct child_prog *child) | |||
429 | return EXIT_FAILURE; | 429 | return EXIT_FAILURE; |
430 | } | 430 | } |
431 | cwd = xgetcwd(cwd); | 431 | cwd = xgetcwd(cwd); |
432 | if (!cwd) | ||
433 | cwd = unknown; | ||
432 | return EXIT_SUCCESS; | 434 | return EXIT_SUCCESS; |
433 | } | 435 | } |
434 | 436 | ||
@@ -568,6 +570,8 @@ static int builtin_jobs(struct child_prog *child) | |||
568 | static int builtin_pwd(struct child_prog *dummy) | 570 | static int builtin_pwd(struct child_prog *dummy) |
569 | { | 571 | { |
570 | cwd = xgetcwd(cwd); | 572 | cwd = xgetcwd(cwd); |
573 | if (!cwd) | ||
574 | cwd = unknown; | ||
571 | puts(cwd); | 575 | puts(cwd); |
572 | return EXIT_SUCCESS; | 576 | return EXIT_SUCCESS; |
573 | } | 577 | } |
@@ -2307,6 +2311,8 @@ int shell_main(int argc, char **argv) | |||
2307 | 2311 | ||
2308 | /* initialize the cwd -- this is never freed...*/ | 2312 | /* initialize the cwd -- this is never freed...*/ |
2309 | cwd = xgetcwd(0); | 2313 | cwd = xgetcwd(0); |
2314 | if (!cwd) | ||
2315 | cwd = unknown; | ||
2310 | #ifdef BB_FEATURE_COMMAND_EDITING | 2316 | #ifdef BB_FEATURE_COMMAND_EDITING |
2311 | cmdedit_set_initial_prompt(); | 2317 | cmdedit_set_initial_prompt(); |
2312 | #else | 2318 | #else |