summaryrefslogtreecommitdiffstats
path: root/src/rule.c
diff options
context:
space:
mode:
authorCarlos Falgueras García <carlosfg@riseup.net>2016-07-11 18:07:40 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2016-07-11 19:14:54 +0200
commitbda7102d60bfdab2aa3f36ebd09a119206f264d0 (patch)
treeb53ca0f0bc4aefa48d408276f7b62f62c5a4ede5 /src/rule.c
parent8f1e916b9856785cb835a2d550c9605e86937055 (diff)
src: Fix nftnl_*_get_data() to return the real attribute length
All getters must set the memory size of the attributes, ie. this includes the nul-termination in strings. For references to opaque objects hidden behind the curtain, report a zero size. Signed-off-by: Carlos Falgueras García <carlosfg@riseup.net> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/rule.c')
-rw-r--r--src/rule.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/rule.c b/src/rule.c
index 2b23c8e..a0edca7 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -213,8 +213,10 @@ const void *nftnl_rule_get_data(const struct nftnl_rule *r, uint16_t attr,
*data_len = sizeof(uint32_t);
return &r->family;
case NFTNL_RULE_TABLE:
+ *data_len = strlen(r->table) + 1;
return r->table;
case NFTNL_RULE_CHAIN:
+ *data_len = strlen(r->chain) + 1;
return r->chain;
case NFTNL_RULE_HANDLE:
*data_len = sizeof(uint64_t);