diff options
author | Michael Santos <michael.santos@gmail.com> | 2011-03-19 11:10:34 -0400 |
---|---|---|
committer | Daniel Lezcano <dlezcano@fr.ibm.com> | 2011-03-22 15:04:52 +0100 |
commit | 6d10f1fcdc50789ffab87313a9b54d15ba4365db (patch) | |
tree | 9ac745366485da199e2acd24e4c1777549788088 /src | |
parent | network: ensure interface name is NULL terminated (diff) | |
download | lxc-6d10f1fcdc50789ffab87313a9b54d15ba4365db.tar.gz lxc-6d10f1fcdc50789ffab87313a9b54d15ba4365db.tar.bz2 lxc-6d10f1fcdc50789ffab87313a9b54d15ba4365db.zip |
arguments: check allocation succeeds
Signed-off-by: Michael Santos <michael.santos@gmail.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/lxc/arguments.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/lxc/arguments.c b/src/lxc/arguments.c index 3c11661..51ebadb 100644 --- a/src/lxc/arguments.c +++ b/src/lxc/arguments.c @@ -96,6 +96,9 @@ static void print_usage(const struct option longopts[], int j; char *uppername = strdup(opt->name); + if (!uppername) + exit(-ENOMEM); + for (j = 0; uppername[j]; j++) uppername[j] = toupper(uppername[j]); @@ -217,15 +220,22 @@ extern char **lxc_arguments_dup(const char *file, struct lxc_arguments *args) nbargs = 0; - argv[nbargs++] = strdup(file); + argv[nbargs] = strdup(file); + if (!argv[nbargs]) + return NULL; + nbargs++; if (args->quiet) argv[nbargs++] = "--quiet"; argv[nbargs++] = "--"; - for (opt = 0; opt < args->argc; opt++) - argv[nbargs++] = strdup(args->argv[opt]); + for (opt = 0; opt < args->argc; opt++) { + argv[nbargs] = strdup(args->argv[opt]); + if (!argv[nbargs]) + return NULL; + nbargs++; + } argv[nbargs] = NULL; |