From bda7102d60bfdab2aa3f36ebd09a119206f264d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Falgueras=20Garc=C3=ADa?= Date: Mon, 11 Jul 2016 18:07:40 +0200 Subject: src: Fix nftnl_*_get_data() to return the real attribute length MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Pablo Neira Ayuso --- src/chain.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/chain.c') diff --git a/src/chain.c b/src/chain.c index cab64b5..4c562fe 100644 --- a/src/chain.c +++ b/src/chain.c @@ -272,8 +272,10 @@ const void *nftnl_chain_get_data(const struct nftnl_chain *c, uint16_t attr, switch(attr) { case NFTNL_CHAIN_NAME: + *data_len = strlen(c->name) + 1; return c->name; case NFTNL_CHAIN_TABLE: + *data_len = strlen(c->table) + 1; return c->table; case NFTNL_CHAIN_HOOKNUM: *data_len = sizeof(uint32_t); @@ -303,6 +305,7 @@ const void *nftnl_chain_get_data(const struct nftnl_chain *c, uint16_t attr, *data_len = sizeof(uint32_t); return c->type; case NFTNL_CHAIN_DEV: + *data_len = strlen(c->dev) + 1; return c->dev; } return NULL; -- cgit v1.2.3