All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Fernando Fernandez Mancera <ffmancera@riseup.net>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH 1/2 nft] jump: Introduce chain_expr in jump and goto statements
Date: Wed, 15 May 2019 00:54:18 +0200	[thread overview]
Message-ID: <20190514225418.qi7nm6htm3v4fner@salvia> (raw)
In-Reply-To: <20190514211340.913-1-ffmancera@riseup.net>

On Tue, May 14, 2019 at 11:13:39PM +0200, Fernando Fernandez Mancera wrote:
[...]
> diff --git a/src/expression.c b/src/expression.c
> index eece12e..55a4ad7 100644
> --- a/src/expression.c
> +++ b/src/expression.c
> @@ -207,17 +207,18 @@ static bool verdict_expr_cmp(const struct expr *e1, const struct expr *e2)
>  
>  	if ((e1->verdict == NFT_JUMP ||
>  	     e1->verdict == NFT_GOTO) &&
> -	    strcmp(e1->chain, e2->chain))
> -		return false;
> +	     (expr_basetype(e1) == expr_basetype(e2) &&
> +	     !mpz_cmp(e1->value, e2->value)))

Maybe replace these two new lines above by:

              expr_cmp(e1->chain, e2->chain)

> +		return true;
>  
> -	return true;
> +	return false;
>  }
>  
>  static void verdict_expr_clone(struct expr *new, const struct expr *expr)
>  {
>  	new->verdict = expr->verdict;
>  	if (expr->chain != NULL)
> -		new->chain = xstrdup(expr->chain);
> +		mpz_init_set(new->chain->value, expr->chain->value);
>  }
>  
>  static void verdict_expr_destroy(struct expr *expr)

Memleak here in verdict_expr_destroy(), you need to call:

        expr_free(expr->chain);

instead of:

        xfree(expr->chain)

Please, run valgrind with --leak-check=full to make sure there are no
leaks either from adding a new rule nor when listing the ruleset.

Thanks!

      parent reply	other threads:[~2019-05-14 22:54 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-14 21:13 [PATCH 1/2 nft] jump: Introduce chain_expr in jump and goto statements Fernando Fernandez Mancera
2019-05-14 21:13 ` [PATCH 2/2 nft] jump: Allow goto and jump to a variable using nft input files Fernando Fernandez Mancera
2019-05-14 22:55   ` Pablo Neira Ayuso
2019-05-15 10:46   ` Phil Sutter
2019-05-15 10:49     ` Fernando Fernandez Mancera
2019-05-15 10:58   ` Phil Sutter
2019-05-15 11:02     ` Fernando Fernandez Mancera
2019-05-15 11:12       ` Pablo Neira Ayuso
2019-05-15 11:46         ` Phil Sutter
2019-05-15 15:21           ` Pablo Neira Ayuso
2019-05-15 19:26             ` Phil Sutter
2019-05-15 19:56               ` Fernando Fernandez Mancera
2019-05-15 20:31                 ` Phil Sutter
2019-05-16 11:58                   ` Fernando Fernandez Mancera
2019-05-16 14:39                     ` Pablo Neira Ayuso
2019-05-16 14:42                       ` Fernando Fernandez Mancera
2019-05-14 22:54 ` Pablo Neira Ayuso [this message]

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=20190514225418.qi7nm6htm3v4fner@salvia \
    --to=pablo@netfilter.org \
    --cc=ffmancera@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.