aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorMatt Kraai <kraai@debian.org>2001-05-02 14:48:48 +0000
committerMatt Kraai <kraai@debian.org>2001-05-02 14:48:48 +0000
commitf162e7d09d4023bb8c7e15d80105f46da4b92437 (patch)
tree49992f16b671c04756442916a49fd369942cf25e /shell
parente67c3ce327379c48a7210f4decdd93692d6c5176 (diff)
downloadbusybox-w32-f162e7d09d4023bb8c7e15d80105f46da4b92437.tar.gz
busybox-w32-f162e7d09d4023bb8c7e15d80105f46da4b92437.tar.bz2
busybox-w32-f162e7d09d4023bb8c7e15d80105f46da4b92437.zip
Don't segfault if the first word is the empty string.
Diffstat (limited to 'shell')
-rw-r--r--shell/hush.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/shell/hush.c b/shell/hush.c
index 2e65f0b6d..9134251f5 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -1298,7 +1298,7 @@ static int globhack(const char *src, int flags, glob_t *pglob)
1298 int cnt, pathc; 1298 int cnt, pathc;
1299 const char *s; 1299 const char *s;
1300 char *dest; 1300 char *dest;
1301 for (cnt=1, s=src; *s; s++) { 1301 for (cnt=1, s=src; s && *s; s++) {
1302 if (*s == '\\') s++; 1302 if (*s == '\\') s++;
1303 cnt++; 1303 cnt++;
1304 } 1304 }
@@ -1315,7 +1315,7 @@ static int globhack(const char *src, int flags, glob_t *pglob)
1315 if (pglob->gl_pathv == NULL) return GLOB_NOSPACE; 1315 if (pglob->gl_pathv == NULL) return GLOB_NOSPACE;
1316 pglob->gl_pathv[pathc-1]=dest; 1316 pglob->gl_pathv[pathc-1]=dest;
1317 pglob->gl_pathv[pathc]=NULL; 1317 pglob->gl_pathv[pathc]=NULL;
1318 for (s=src; *s; s++, dest++) { 1318 for (s=src; s && *s; s++, dest++) {
1319 if (*s == '\\') s++; 1319 if (*s == '\\') s++;
1320 *dest = *s; 1320 *dest = *s;
1321 } 1321 }
@@ -1482,6 +1482,8 @@ int reserved_word(o_string *dest, struct p_context *ctx)
1482 { "done", RES_DONE, FLAG_END } 1482 { "done", RES_DONE, FLAG_END }
1483 }; 1483 };
1484 struct reserved_combo *r; 1484 struct reserved_combo *r;
1485 if (dest->data == NULL)
1486 return 0;
1485 for (r=reserved_list; 1487 for (r=reserved_list;
1486#define NRES sizeof(reserved_list)/sizeof(struct reserved_combo) 1488#define NRES sizeof(reserved_list)/sizeof(struct reserved_combo)
1487 r<reserved_list+NRES; r++) { 1489 r<reserved_list+NRES; r++) {