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/set.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/set.c') diff --git a/src/set.c b/src/set.c index e48ff78..8a592db 100644 --- a/src/set.c +++ b/src/set.c @@ -215,8 +215,10 @@ const void *nftnl_set_get_data(const struct nftnl_set *s, uint16_t attr, switch(attr) { case NFTNL_SET_TABLE: + *data_len = strlen(s->table) + 1; return s->table; case NFTNL_SET_NAME: + *data_len = strlen(s->name) + 1; return s->name; case NFTNL_SET_FLAGS: *data_len = sizeof(uint32_t); -- cgit v1.2.3