summaryrefslogtreecommitdiffstats
path: root/libxtables/xtoptions.c
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2021-06-02 12:56:06 +0200
committerPhil Sutter <phil@nwl.cc>2021-06-07 14:50:27 +0200
commit9b85e1ab3dbf0d9344562c5c76114496e3ebaa3a (patch)
tree297ae64c83a98f3b8c1e4ab0b739df1110cbe067 /libxtables/xtoptions.c
parentca840c20b7b754d36a1abe7e597fd730dea142d4 (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 'libxtables/xtoptions.c')
-rw-r--r--libxtables/xtoptions.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/libxtables/xtoptions.c b/libxtables/xtoptions.c
index 0dcdf607..9d3ac5c8 100644
--- a/libxtables/xtoptions.c
+++ b/libxtables/xtoptions.c
@@ -604,9 +604,7 @@ static void xtopt_parse_mport(struct xt_option_call *cb)
unsigned int maxiter;
int value;
- wp_arg = lo_arg = strdup(cb->arg);
- if (lo_arg == NULL)
- xt_params->exit_err(RESOURCE_PROBLEM, "strdup");
+ wp_arg = lo_arg = xtables_strdup(cb->arg);
maxiter = entry->size / esize;
if (maxiter == 0)
@@ -747,9 +745,7 @@ static void xtopt_parse_hostmask(struct xt_option_call *cb)
xtopt_parse_host(cb);
return;
}
- work = strdup(orig_arg);
- if (work == NULL)
- xt_params->exit_err(PARAMETER_PROBLEM, "strdup");
+ work = xtables_strdup(orig_arg);
p = strchr(work, '/'); /* by def this can't be NULL now */
*p++ = '\0';
/*
@@ -1139,11 +1135,7 @@ struct xtables_lmap *xtables_lmap_init(const char *file)
goto out;
}
lmap_this->id = id;
- lmap_this->name = strdup(cur);
- if (lmap_this->name == NULL) {
- free(lmap_this);
- goto out;
- }
+ lmap_this->name = xtables_strdup(cur);
lmap_this->next = NULL;
if (lmap_prev != NULL)