From 9b85e1ab3dbf0d9344562c5c76114496e3ebaa3a Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Wed, 2 Jun 2021 12:56:06 +0200 Subject: libxtables: Introduce xtables_strdup() and use it everywhere This wraps strdup(), checking for errors. Signed-off-by: Phil Sutter --- extensions/libipt_DNAT.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'extensions/libipt_DNAT.c') diff --git a/extensions/libipt_DNAT.c b/extensions/libipt_DNAT.c index 4907a2e8..5b33fd23 100644 --- a/extensions/libipt_DNAT.c +++ b/extensions/libipt_DNAT.c @@ -79,9 +79,7 @@ parse_to(const char *orig_arg, int portok, struct ipt_natinfo *info) char *arg, *colon, *dash, *error; const struct in_addr *ip; - arg = strdup(orig_arg); - if (arg == NULL) - xtables_error(RESOURCE_PROBLEM, "strdup"); + arg = xtables_strdup(orig_arg); memset(&range, 0, sizeof(range)); colon = strchr(arg, ':'); @@ -302,9 +300,7 @@ parse_to_v2(const char *orig_arg, int portok, struct nf_nat_range2 *range) char *arg, *colon, *dash, *error; const struct in_addr *ip; - arg = strdup(orig_arg); - if (arg == NULL) - xtables_error(RESOURCE_PROBLEM, "strdup"); + arg = xtables_strdup(orig_arg); colon = strchr(arg, ':'); if (colon) { -- cgit v1.2.3