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/expr/dynset.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/expr/dynset.c') diff --git a/src/expr/dynset.c b/src/expr/dynset.c index 0404359..111bf8c 100644 --- a/src/expr/dynset.c +++ b/src/expr/dynset.c @@ -88,10 +88,13 @@ nftnl_expr_dynset_get(const struct nftnl_expr *e, uint16_t type, *data_len = sizeof(dynset->timeout); return &dynset->timeout; case NFTNL_EXPR_DYNSET_SET_NAME: + *data_len = strlen(dynset->set_name) + 1; return dynset->set_name; case NFTNL_EXPR_DYNSET_SET_ID: + *data_len = sizeof(dynset->set_id); return &dynset->set_id; case NFTNL_EXPR_DYNSET_EXPR: + *data_len = 0; return dynset->expr; } return NULL; -- cgit v1.2.3