aboutsummaryrefslogtreecommitdiff
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
parente67c3ce327379c48a7210f4decdd93692d6c5176 (diff)
downloadbusybox-f162e7d09d4023bb8c7e15d80105f46da4b92437.tar.gz
Don't segfault if the first word is the empty string.
-rw-r--r--hush.c6
-rw-r--r--shell/hush.c6
2 files changed, 8 insertions, 4 deletions
diff --git a/hush.c b/hush.c
index 2e65f0b6d..9134251f5 100644
--- a/hush.c
+++ b/hush.c
@@ -1298,7 +1298,7 @@ static int globhack(const char *src, int flags, glob_t *pglob)
int cnt, pathc;
const char *s;
char *dest;
- for (cnt=1, s=src; *s; s++) {
+ for (cnt=1, s=src; s && *s; s++) {
if (*s == '\\') s++;
cnt++;
}
@@ -1315,7 +1315,7 @@ static int globhack(const char *src, int flags, glob_t *pglob)
if (pglob->gl_pathv == NULL) return GLOB_NOSPACE;
pglob->gl_pathv[pathc-1]=dest;
pglob->gl_pathv[pathc]=NULL;
- for (s=src; *s; s++, dest++) {
+ for (s=src; s && *s; s++, dest++) {
if (*s == '\\') s++;
*dest = *s;
}
@@ -1482,6 +1482,8 @@ int reserved_word(o_string *dest, struct p_context *ctx)
{ "done", RES_DONE, FLAG_END }
};
struct reserved_combo *r;
+ if (dest->data == NULL)
+ return 0;
for (r=reserved_list;
#define NRES sizeof(reserved_list)/sizeof(struct reserved_combo)
r<reserved_list+NRES; r++) {
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)
int cnt, pathc;
const char *s;
char *dest;
- for (cnt=1, s=src; *s; s++) {
+ for (cnt=1, s=src; s && *s; s++) {
if (*s == '\\') s++;
cnt++;
}
@@ -1315,7 +1315,7 @@ static int globhack(const char *src, int flags, glob_t *pglob)
if (pglob->gl_pathv == NULL) return GLOB_NOSPACE;
pglob->gl_pathv[pathc-1]=dest;
pglob->gl_pathv[pathc]=NULL;
- for (s=src; *s; s++, dest++) {
+ for (s=src; s && *s; s++, dest++) {
if (*s == '\\') s++;
*dest = *s;
}
@@ -1482,6 +1482,8 @@ int reserved_word(o_string *dest, struct p_context *ctx)
{ "done", RES_DONE, FLAG_END }
};
struct reserved_combo *r;
+ if (dest->data == NULL)
+ return 0;
for (r=reserved_list;
#define NRES sizeof(reserved_list)/sizeof(struct reserved_combo)
r<reserved_list+NRES; r++) {