diff options
author | Phil Sutter <phil@nwl.cc> | 2021-06-02 12:56:06 +0200 |
---|---|---|
committer | Phil Sutter <phil@nwl.cc> | 2021-06-07 14:50:27 +0200 |
commit | 9b85e1ab3dbf0d9344562c5c76114496e3ebaa3a (patch) | |
tree | 297ae64c83a98f3b8c1e4ab0b739df1110cbe067 /iptables/nft-cmd.c | |
parent | ca840c20b7b754d36a1abe7e597fd730dea142d4 (diff) |
libxtables: Introduce xtables_strdup() and use it everywhere
This wraps strdup(), checking for errors.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'iptables/nft-cmd.c')
-rw-r--r-- | iptables/nft-cmd.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/iptables/nft-cmd.c b/iptables/nft-cmd.c index c3f6c14e..a0c76a79 100644 --- a/iptables/nft-cmd.c +++ b/iptables/nft-cmd.c @@ -11,6 +11,7 @@ #include <stdlib.h> #include <string.h> +#include <xtables.h> #include "nft.h" #include "nft-cmd.h" @@ -27,9 +28,9 @@ struct nft_cmd *nft_cmd_new(struct nft_handle *h, int command, return NULL; cmd->command = command; - cmd->table = strdup(table); + cmd->table = xtables_strdup(table); if (chain) - cmd->chain = strdup(chain); + cmd->chain = xtables_strdup(chain); cmd->rulenum = rulenum; cmd->verbose = verbose; @@ -43,7 +44,7 @@ struct nft_cmd *nft_cmd_new(struct nft_handle *h, int command, cmd->obj.rule = rule; if (!state->target && strlen(state->jumpto) > 0) - cmd->jumpto = strdup(state->jumpto); + cmd->jumpto = xtables_strdup(state->jumpto); } list_add_tail(&cmd->head, &h->cmd_list); @@ -238,7 +239,7 @@ int nft_cmd_chain_user_rename(struct nft_handle *h,const char *chain, if (!cmd) return 0; - cmd->rename = strdup(newname); + cmd->rename = xtables_strdup(newname); nft_cache_level_set(h, NFT_CL_CHAINS, cmd); @@ -304,7 +305,7 @@ int nft_cmd_chain_set(struct nft_handle *h, const char *table, if (!cmd) return 0; - cmd->policy = strdup(policy); + cmd->policy = xtables_strdup(policy); if (counters) cmd->counters = *counters; @@ -389,7 +390,7 @@ int ebt_cmd_user_chain_policy(struct nft_handle *h, const char *table, if (!cmd) return 0; - cmd->policy = strdup(policy); + cmd->policy = xtables_strdup(policy); nft_cache_level_set(h, NFT_CL_RULES, cmd); |