aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorkraai <kraai@69ca8d6d-28ef-0310-b511-8ec308f3f277>2001-05-02 14:48:48 +0000
committerkraai <kraai@69ca8d6d-28ef-0310-b511-8ec308f3f277>2001-05-02 14:48:48 +0000
commit41fc1112786937c53bdda70d8c468e3b8b65da81 (patch)
tree49992f16b671c04756442916a49fd369942cf25e /shell
parent7b1a2b9d026823684c138acf1167058d204463d2 (diff)
downloadbusybox-w32-41fc1112786937c53bdda70d8c468e3b8b65da81.tar.gz
busybox-w32-41fc1112786937c53bdda70d8c468e3b8b65da81.tar.bz2
busybox-w32-41fc1112786937c53bdda70d8c468e3b8b65da81.zip
Don't segfault if the first word is the empty string.
git-svn-id: svn://busybox.net/trunk/busybox@2510 69ca8d6d-28ef-0310-b511-8ec308f3f277
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++) {