netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: "Carlos Falgueras García" <carlosfg@riseup.net>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH libnftnl] Fix string length calculations
Date: Sat, 2 Jul 2016 08:54:48 +0200	[thread overview]
Message-ID: <20160702065316.GA26375@salvia> (raw)
In-Reply-To: <1467389503-27143-1-git-send-email-carlosfg@riseup.net>

On Fri, Jul 01, 2016 at 06:11:43PM +0200, Carlos Falgueras García wrote:
> These lengths must be one character longer to take account the null
> character

Please, place the change for src/set.c in this patch so I only need to
apply one patch.

Another comment below.

> Signed-off-by: Carlos Falgueras García <carlosfg@riseup.net>
> ---
>  src/chain.c    | 2 +-
>  src/rule.c     | 2 +-
>  src/set_elem.c | 2 +-
>  src/table.c    | 2 +-
>  src/trace.c    | 6 +++---
>  5 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/src/chain.c b/src/chain.c
> index bfffbe0..cab64b5 100644
> --- a/src/chain.c
> +++ b/src/chain.c
> @@ -260,7 +260,7 @@ EXPORT_SYMBOL_ALIAS(nftnl_chain_set_u8, nft_chain_attr_set_u8);
>  
>  int nftnl_chain_set_str(struct nftnl_chain *c, uint16_t attr, const char *str)
>  {
> -	return nftnl_chain_set_data(c, attr, str, strlen(str));
> +	return nftnl_chain_set_data(c, attr, str, strlen(str) + 1);
>  }
>  EXPORT_SYMBOL_ALIAS(nftnl_chain_set_str, nft_chain_attr_set_str);
>  
> diff --git a/src/rule.c b/src/rule.c
> index c87fea7..2b23c8e 100644
> --- a/src/rule.c
> +++ b/src/rule.c
> @@ -198,7 +198,7 @@ EXPORT_SYMBOL_ALIAS(nftnl_rule_set_u64, nft_rule_attr_set_u64);
>  
>  int nftnl_rule_set_str(struct nftnl_rule *r, uint16_t attr, const char *str)
>  {
> -	return nftnl_rule_set_data(r, attr, str, strlen(str));
> +	return nftnl_rule_set_data(r, attr, str, strlen(str) + 1);
>  }
>  EXPORT_SYMBOL_ALIAS(nftnl_rule_set_str, nft_rule_attr_set_str);
>  
> diff --git a/src/set_elem.c b/src/set_elem.c
> index 00b7327..40b5bfe 100644
> --- a/src/set_elem.c
> +++ b/src/set_elem.c
> @@ -149,7 +149,7 @@ EXPORT_SYMBOL_ALIAS(nftnl_set_elem_set_u64, nft_set_elem_attr_set_u64);
>  
>  int nftnl_set_elem_set_str(struct nftnl_set_elem *s, uint16_t attr, const char *str)
>  {
> -	return nftnl_set_elem_set(s, attr, str, strlen(str));
> +	return nftnl_set_elem_set(s, attr, str, strlen(str) + 1);
>  }
>  EXPORT_SYMBOL_ALIAS(nftnl_set_elem_set_str, nft_set_elem_attr_set_str);
>  
> diff --git a/src/table.c b/src/table.c
> index 32d119f..966b923 100644
> --- a/src/table.c
> +++ b/src/table.c
> @@ -131,7 +131,7 @@ EXPORT_SYMBOL_ALIAS(nftnl_table_set_u8, nft_table_attr_set_u8);
>  
>  int nftnl_table_set_str(struct nftnl_table *t, uint16_t attr, const char *str)
>  {
> -	return nftnl_table_set_data(t, attr, str, 0);
> +	return nftnl_table_set_data(t, attr, str, strlen(str) + 1);
>  }
>  EXPORT_SYMBOL_ALIAS(nftnl_table_set_str, nft_table_attr_set_str);
>  
> 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?
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2016-07-02  6:54 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-27 16:24 [PATCH libnftnl] set: Fix nftnl_set_set_str Carlos Falgueras García
2016-06-27 16:29 ` Carlos Falgueras García
2016-07-01 14:22 ` Pablo Neira Ayuso
2016-07-01 16:07   ` [PATCH libnfntl v2] " Carlos Falgueras García
2016-07-01 16:11   ` [PATCH libnftnl] Fix string length calculations Carlos Falgueras García
2016-07-02  6:54     ` Pablo Neira Ayuso [this message]
2016-07-03 10:13       ` Carlos Falgueras García
2016-07-05 12:31         ` Pablo Neira Ayuso
2016-07-05 17:15           ` [PATCH 1/2 libnfntl] Fix nftnl_*_set_str Carlos Falgueras García
2016-07-05 17:15             ` [PATCH 2/2 libnfntl] Fix nftnl_*_get to set data_len Carlos Falgueras García
2016-07-06 15:21               ` Pablo Neira Ayuso
2016-07-11 11:41                 ` [PATCH v2, libnftnl] " Carlos Falgueras García
2016-07-11 11:48                   ` Pablo Neira Ayuso
2016-07-11 16:07                     ` [PATCH v3, " Carlos Falgueras García
2016-07-11 17:18                       ` Pablo Neira Ayuso
2016-07-11 10:24               ` [PATCH 2/2 libnfntl] " Pablo Neira Ayuso
2016-07-11 10:25                 ` Pablo Neira Ayuso
2016-07-06 15:19             ` [PATCH 1/2 libnfntl] Fix nftnl_*_set_str Pablo Neira Ayuso
2016-07-01 16:13   ` [PATCH libnftnl] set: Fix nftnl_set_set_str Carlos Falgueras García

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160702065316.GA26375@salvia \
    --to=pablo@netfilter.org \
    --cc=carlosfg@riseup.net \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).