diff options
author | Phil Sutter <phil@nwl.cc> | 2021-08-31 12:29:43 +0200 |
---|---|---|
committer | Phil Sutter <phil@nwl.cc> | 2021-08-31 18:19:04 +0200 |
commit | e438b9766fcc86d9847312ff05f1d1dac61acf1f (patch) | |
tree | 2a7a550cd343caadb67a2e2331d533c56dc0f4da /iptables/xtables-eb.c | |
parent | ca11c7b7036b5821c17b8d08dc2a29f55b461a93 (diff) |
nft: Use xtables_{m,c}alloc() everywhere
Make use of libxtables allocators where sensible to have implicit error
checking. Leave library-internal calls in place to not create unexpected
program exit points for users, apart from xt_xlate_alloc() as that
function called xtables_error() in error case which exits by itself
already.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'iptables/xtables-eb.c')
-rw-r--r-- | iptables/xtables-eb.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/iptables/xtables-eb.c b/iptables/xtables-eb.c index 6e35f58e..6e5ecd48 100644 --- a/iptables/xtables-eb.c +++ b/iptables/xtables-eb.c @@ -274,9 +274,7 @@ static struct option *merge_options(struct option *oldopts, ebtables_globals.option_offset += OPTION_OFFSET; *options_offset = ebtables_globals.option_offset; - merge = malloc(sizeof(struct option) * (num_new + num_old + 1)); - if (!merge) - return NULL; + merge = xtables_malloc(sizeof(struct option) * (num_new + num_old + 1)); memcpy(merge, oldopts, num_old * sizeof(struct option)); for (i = 0; i < num_new; i++) { merge[num_old + i] = newopts[i]; @@ -571,10 +569,7 @@ void ebt_add_match(struct xtables_match *m, m->mflags = 0; /* glue code for watchers */ - newnode = calloc(1, sizeof(struct ebt_match)); - if (newnode == NULL) - xtables_error(OTHER_PROBLEM, "Unable to alloc memory"); - + newnode = xtables_calloc(1, sizeof(struct ebt_match)); newnode->ismatch = true; newnode->u.match = newm; @@ -603,10 +598,7 @@ void ebt_add_watcher(struct xtables_target *watcher, watcher->tflags = 0; - newnode = calloc(1, sizeof(struct ebt_match)); - if (newnode == NULL) - xtables_error(OTHER_PROBLEM, "Unable to alloc memory"); - + newnode = xtables_calloc(1, sizeof(struct ebt_match)); newnode->u.watcher = clone; for (matchp = &cs->match_list; *matchp; matchp = &(*matchp)->next) |