summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2016-06-22 19:30:21 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2016-06-22 19:31:19 +0200
commit3ec2592cd94a1e16ea1aadf6ff3632260deba600 (patch)
treef286fa26f081ad7c867deb7e4e04e780f9f99d55
parent59cb13bb62b36efa25b29fe280ada7b1f0984325 (diff)
set_elem: fix return in several error paths of nftnl_set_elems_parse2()
They don't set ret to anything, and ret is not initialized, so we return garbage. Fixes: 59cb13b ("src: fix missing error checking in parser functions") Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r--src/set_elem.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/set_elem.c b/src/set_elem.c
index 94b50f9..00b7327 100644
--- a/src/set_elem.c
+++ b/src/set_elem.c
@@ -393,8 +393,10 @@ static int nftnl_set_elems_parse2(struct nftnl_set *s, const struct nlattr *nest
}
if (tb[NFTA_SET_ELEM_EXPR]) {
e->expr = nftnl_expr_parse(tb[NFTA_SET_ELEM_EXPR]);
- if (e->expr == NULL)
+ if (e->expr == NULL) {
+ ret = -1;
goto out_set_elem;
+ }
e->flags |= (1 << NFTNL_SET_ELEM_EXPR);
}
if (tb[NFTA_SET_ELEM_USERDATA]) {
@@ -406,8 +408,10 @@ static int nftnl_set_elems_parse2(struct nftnl_set *s, const struct nlattr *nest
e->user.len = mnl_attr_get_payload_len(tb[NFTA_SET_ELEM_USERDATA]);
e->user.data = malloc(e->user.len);
- if (e->user.data == NULL)
+ if (e->user.data == NULL) {
+ ret = -1;
goto out_expr;
+ }
memcpy(e->user.data, udata, e->user.len);
e->flags |= (1 << NFTNL_RULE_USERDATA);
}