Re: [PATCH libnftnl] Fix string length calculations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Jul 03, 2016 at 12:13:18PM +0200, Carlos Falgueras García wrote:
> >>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;
> >Are you really sure we need this chunk too?
> Yes, I think the user would expect that 'data_len' means data length instead
> of data length minus one.
> 
> When checking other getters I realized that in most cases we keep the
> parameter 'data_len' unset when the user ask for a string. Maybe we can fix
> these behavior, I think it make more sense if our getters always return the
> data length instead of keep an inconstant behavior.

_get() for strings functions should retain the strlen() semantics.

So I'd suggest you just fix the string setters.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux