summaryrefslogtreecommitdiffstats
path: root/iptables.c
diff options
context:
space:
mode:
author/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org </C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org>2008-01-17 17:30:27 +0000
committer/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org </C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org>2008-01-17 17:30:27 +0000
commit706bfe7a140f8f90b08f20682a465127337fd5d1 (patch)
tree5718a82c3af66032b386e8896819f8d7dbf5e23f /iptables.c
parentecbd02d437631e7a0856b07a8427af6836705f49 (diff)
- cleanup several code wraparounds
- check for malloc() return value in merge_opts() - check for merge_opts() return value
Diffstat (limited to 'iptables.c')
-rw-r--r--iptables.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/iptables.c b/iptables.c
index 7096121..16726d3 100644
--- a/iptables.c
+++ b/iptables.c
@@ -863,6 +863,8 @@ merge_options(struct option *oldopts, const struct option *newopts,
*option_offset = global_option_offset;
merge = malloc(sizeof(struct option) * (num_new + num_old + 1));
+ if (merge == NULL)
+ return NULL;
memcpy(merge, oldopts, num_old * sizeof(struct option));
free_opts(0); /* Release previous options merged if any */
for (i = 0; i < num_new; i++) {
@@ -1689,7 +1691,12 @@ int do_command(int argc, char *argv[], char **table, iptc_handle_t *handle)
target->revision);
if (target->init != NULL)
target->init(target->t);
- opts = merge_options(opts, target->extra_opts, &target->option_offset);
+ opts = merge_options(opts,
+ target->extra_opts,
+ &target->option_offset);
+ if (opts == NULL)
+ exit_error(OTHER_PROBLEM,
+ "can't alloc memory!");
}
break;
@@ -1741,9 +1748,15 @@ int do_command(int argc, char *argv[], char **table, iptc_handle_t *handle)
set_revision(m->m->u.user.name, m->revision);
if (m->init != NULL)
m->init(m->m);
- if (m != m->next)
+ if (m != m->next) {
/* Merge options for non-cloned matches */
- opts = merge_options(opts, m->extra_opts, &m->option_offset);
+ opts = merge_options(opts,
+ m->extra_opts,
+ &m->option_offset);
+ if (opts == NULL)
+ exit_error(OTHER_PROBLEM,
+ "can't alloc memory!");
+ }
}
break;
@@ -1889,7 +1902,11 @@ int do_command(int argc, char *argv[], char **table, iptc_handle_t *handle)
m->init(m->m);
opts = merge_options(opts,
- m->extra_opts, &m->option_offset);
+ m->extra_opts,
+ &m->option_offset);
+ if (opts == NULL)
+ exit_error(OTHER_PROBLEM,
+ "can't alloc memory!");
optind--;
continue;