call nftnl_rule_is_set(NFTNL_RULE_USERDATA) before nftnl_rule_get_data(NFTNL_RULE_USERDATA)

see #459 and #461
This commit is contained in:
Thomas Bernard 2020-05-29 18:10:30 +02:00
parent 827fc6f041
commit 6cd5ca6e9a
No known key found for this signature in database
GPG Key ID: 0FF11B67A5C0863C
1 changed files with 8 additions and 6 deletions

View File

@ -1,4 +1,4 @@
/* $Id: nftnlrdr_misc.c,v 1.8 2020/05/10 17:04:46 nanard Exp $ */
/* $Id: nftnlrdr_misc.c,v 1.9 2020/05/29 16:09:21 nanard Exp $ */
/*
* MiniUPnP project
* http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
@ -482,7 +482,6 @@ table_cb(const struct nlmsghdr *nlh, void *data)
struct nftnl_expr_iter *itr;
rule_t *r;
char *chain;
char *descr;
int index_filter, index_peer, index_redirect;
UNUSED(data);
@ -511,10 +510,13 @@ table_cb(const struct nlmsghdr *nlh, void *data)
r->chain = strdup(chain);
r->family = *(uint32_t *) nftnl_rule_get_data(rule, NFTNL_RULE_FAMILY,
&len);
if (nftnl_rule_is_set(rule, NFTNL_RULE_USERDATA)) {
char *descr;
descr = (char *) nftnl_rule_get_data(rule, NFTNL_RULE_USERDATA,
&r->desc_len);
if (r->desc_len > 0)
r->desc = strndup(descr, r->desc_len);
}
r->handle = *(uint32_t *) nftnl_rule_get_data(rule,
NFTNL_RULE_HANDLE,