aboutsummaryrefslogtreecommitdiff
path: root/shell/lash.c
diff options
context:
space:
mode:
authorandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2001-05-11 16:58:46 +0000
committerandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2001-05-11 16:58:46 +0000
commit8ff167e7105b330d069ffff351be3eae1df337e8 (patch)
treee6644e9f97dab0198ad771e1d330e02a7cce8553 /shell/lash.c
parentcbdc734b320c0cde4ca3b25d15add9c6153eb7df (diff)
downloadbusybox-w32-8ff167e7105b330d069ffff351be3eae1df337e8.tar.gz
busybox-w32-8ff167e7105b330d069ffff351be3eae1df337e8.tar.bz2
busybox-w32-8ff167e7105b330d069ffff351be3eae1df337e8.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 git-svn-id: svn://busybox.net/trunk/busybox@2613 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'shell/lash.c')
-rw-r--r--shell/lash.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/shell/lash.c b/shell/lash.c
index 1d128355c..0129d6c02 100644
--- a/shell/lash.c
+++ b/shell/lash.c
@@ -297,7 +297,8 @@ static int builtin_cd(struct child_prog *child)
297 return EXIT_FAILURE; 297 return EXIT_FAILURE;
298 } 298 }
299 cwd = xgetcwd(cwd); 299 cwd = xgetcwd(cwd);
300 300 if (!cwd)
301 cwd = unknown;
301 return EXIT_SUCCESS; 302 return EXIT_SUCCESS;
302} 303}
303 304
@@ -412,6 +413,9 @@ static int builtin_jobs(struct child_prog *child)
412/* built-in 'pwd' handler */ 413/* built-in 'pwd' handler */
413static int builtin_pwd(struct child_prog *dummy) 414static int builtin_pwd(struct child_prog *dummy)
414{ 415{
416 cwd = xgetcwd(cwd);
417 if (!cwd)
418 cwd = unknown;
415 printf( "%s\n", cwd); 419 printf( "%s\n", cwd);
416 return EXIT_SUCCESS; 420 return EXIT_SUCCESS;
417} 421}
@@ -1827,7 +1831,6 @@ void free_memory(void)
1827{ 1831{
1828 if (cwd) { 1832 if (cwd) {
1829 free(cwd); 1833 free(cwd);
1830 cwd = NULL;
1831 } 1834 }
1832 if (local_pending_command) 1835 if (local_pending_command)
1833 free(local_pending_command); 1836 free(local_pending_command);
@@ -1919,6 +1922,8 @@ int shell_main(int argc_l, char **argv_l)
1919 1922
1920 /* initialize the cwd -- this is never freed...*/ 1923 /* initialize the cwd -- this is never freed...*/
1921 cwd = xgetcwd(0); 1924 cwd = xgetcwd(0);
1925 if (!cwd)
1926 cwd = unknown;
1922 1927
1923#ifdef BB_FEATURE_CLEAN_UP 1928#ifdef BB_FEATURE_CLEAN_UP
1924 atexit(free_memory); 1929 atexit(free_memory);