diff options
| author | Jean-Baptiste Queru <jbq@google.com> | 2010-11-24 08:27:17 -0800 |
|---|---|---|
| committer | Android Code Review <code-review@android.com> | 2010-11-24 08:27:17 -0800 |
| commit | 1a15cb7e904a562b0120039816fce5b8e6d5b147 (patch) | |
| tree | 3030f4630c22db03df61436cebda5a7fd81d0a26 | |
| parent | 4906db21e041327042b87122b233e1f150618334 (diff) | |
| parent | a9791e12852a23c762d42aaafa55473cf4a5ed20 (diff) | |
| download | system_core-1a15cb7e904a562b0120039816fce5b8e6d5b147.tar.gz system_core-1a15cb7e904a562b0120039816fce5b8e6d5b147.tar.bz2 system_core-1a15cb7e904a562b0120039816fce5b8e6d5b147.zip | |
Merge "[PATCH] Init - make sure the last parameter to execve is NULL"
| -rw-r--r-- | init/parser.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/init/parser.c b/init/parser.c index 7da0d194..ca03da97 100644 --- a/init/parser.c +++ b/init/parser.c @@ -800,6 +800,7 @@ static void parse_line_action(struct parse_state* state, int nargs, char **args) struct action *act = state->context; int (*func)(int nargs, char **args); int kw, n; + int alloc_size = 0; if (nargs == 0) { return; @@ -817,7 +818,14 @@ static void parse_line_action(struct parse_state* state, int nargs, char **args) n > 2 ? "arguments" : "argument"); return; } - cmd = malloc(sizeof(*cmd) + sizeof(char*) * nargs); + alloc_size = sizeof(*cmd) + sizeof(char*) * (nargs + 1); + cmd = malloc(alloc_size); + if (!cmd) { + parse_error(state, "malloc failed\n"); + return; + } + + memset((char *)cmd, 0, alloc_size); cmd->func = kw_func(kw); cmd->nargs = nargs; memcpy(cmd->args, args, sizeof(char*) * nargs); |
