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/trace.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/trace.c') diff --git a/src/trace.c b/src/trace.c index d8f561d..1a50390 100644 --- a/src/trace.c +++ b/src/trace.c @@ -165,13 +165,13 @@ const void *nftnl_trace_get_data(const struct nftnl_trace *trace, *data_len = sizeof(uint32_t); return &trace->type; case NFTNL_TRACE_CHAIN: - *data_len = strlen(trace->chain); + *data_len = strlen(trace->chain) + 1; return trace->chain; case NFTNL_TRACE_TABLE: - *data_len = strlen(trace->table); + *data_len = strlen(trace->table) + 1; return trace->table; case NFTNL_TRACE_JUMP_TARGET: - *data_len = strlen(trace->jump_target); + *data_len = strlen(trace->jump_target) + 1; return trace->jump_target; case NFTNL_TRACE_TRANSPORT_HEADER: *data_len = trace->th.len; -- cgit v1.2.3