summaryrefslogtreecommitdiffstats
path: root/iptables
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2018-09-24 19:25:26 +0200
committerFlorian Westphal <fw@strlen.de>2018-09-25 16:26:34 +0200
commitb373a91b24c4bb1074f304bc74ce2f361c818a5a (patch)
tree7d3f83d749203fd71ab32348bbcea86f90006f0a /iptables
parent5a4096158261896b9e61837cdb2c081e372e286d (diff)
nft-shared: Use xtables_calloc()
This simplifies code a bit since it takes care of checking for out-of-memory conditions. Signed-off-by: Phil Sutter <phil@nwl.cc> Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'iptables')
-rw-r--r--iptables/nft-shared.c13
1 files changed, 2 insertions, 11 deletions
diff --git a/iptables/nft-shared.c b/iptables/nft-shared.c
index fdd4522c..492e4ec1 100644
--- a/iptables/nft-shared.c
+++ b/iptables/nft-shared.c
@@ -319,11 +319,7 @@ void nft_parse_target(struct nft_xt_ctx *ctx, struct nftnl_expr *e)
size = XT_ALIGN(sizeof(struct xt_entry_target)) + tg_len;
- t = calloc(1, size);
- if (t == NULL) {
- fprintf(stderr, "OOM");
- exit(EXIT_FAILURE);
- }
+ t = xtables_calloc(1, size);
memcpy(&t->data, targinfo, tg_len);
t->u.target_size = size;
t->u.user.revision = nftnl_expr_get_u32(e, NFTNL_EXPR_TG_REV);
@@ -361,12 +357,7 @@ void nft_parse_match(struct nft_xt_ctx *ctx, struct nftnl_expr *e)
if (match == NULL)
return;
- m = calloc(1, sizeof(struct xt_entry_match) + mt_len);
- if (m == NULL) {
- fprintf(stderr, "OOM");
- exit(EXIT_FAILURE);
- }
-
+ m = xtables_calloc(1, sizeof(struct xt_entry_match) + mt_len);
memcpy(&m->data, mt_info, mt_len);
m->u.match_size = mt_len + XT_ALIGN(sizeof(struct xt_entry_match));
m->u.user.revision = nftnl_expr_get_u32(e, NFTNL_EXPR_TG_REV);