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
This commit is contained in:
Eric Andersen
2001-05-11 16:58:46 +00:00
parent 9d94deabd3
commit 5f265b755a
10 changed files with 40 additions and 5 deletions

View File

@@ -429,6 +429,8 @@ static int builtin_cd(struct child_prog *child)
return EXIT_FAILURE;
}
cwd = xgetcwd(cwd);
if (!cwd)
cwd = unknown;
return EXIT_SUCCESS;
}
@@ -568,6 +570,8 @@ static int builtin_jobs(struct child_prog *child)
static int builtin_pwd(struct child_prog *dummy)
{
cwd = xgetcwd(cwd);
if (!cwd)
cwd = unknown;
puts(cwd);
return EXIT_SUCCESS;
}
@@ -2307,6 +2311,8 @@ int shell_main(int argc, char **argv)
/* initialize the cwd -- this is never freed...*/
cwd = xgetcwd(0);
if (!cwd)
cwd = unknown;
#ifdef BB_FEATURE_COMMAND_EDITING
cmdedit_set_initial_prompt();
#else