netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH libnftnl] rule: Fix comparison between rules
@ 2016-08-18 15:12 Carlos Falgueras García
  2016-08-18 16:17 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 2+ messages in thread
From: Carlos Falgueras García @ 2016-08-18 15:12 UTC (permalink / raw)
  To: netfilter-devel; +Cc: pablo

Before this patch, comparison between rules with distinct number of
expressions can returns that they are equals when they are not. Example:

	r1[e1, e2] == r2[e1, e2, e3]

Reported-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Carlos Falgueras García <carlosfg@riseup.net>
---
 src/rule.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/rule.c b/src/rule.c
index ae7c478..9822d63 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -1102,6 +1102,7 @@ bool nftnl_rule_cmp(const struct nftnl_rule *r1, const struct nftnl_rule *r2)
 		e1 = nftnl_expr_iter_next(&it1);
 		e2 = nftnl_expr_iter_next(&it2);
 	}
+	eq &= (e1 == NULL) && (e2 == NULL); /* Same number of expressions */
 
 	return eq;
 }
-- 
2.8.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH libnftnl] rule: Fix comparison between rules
  2016-08-18 15:12 [PATCH libnftnl] rule: Fix comparison between rules Carlos Falgueras García
@ 2016-08-18 16:17 ` Pablo Neira Ayuso
  0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2016-08-18 16:17 UTC (permalink / raw)
  To: Carlos Falgueras García; +Cc: netfilter-devel

On Thu, Aug 18, 2016 at 05:12:36PM +0200, Carlos Falgueras García wrote:
> Before this patch, comparison between rules with distinct number of
> expressions can returns that they are equals when they are not. Example:
> 
> 	r1[e1, e2] == r2[e1, e2, e3]

Applied.

I have mangled patch title to specify a bit more the bug type.

And simplified the code. Remove the comment as 'git annotate' provides
this information already.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-08-19  2:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-18 15:12 [PATCH libnftnl] rule: Fix comparison between rules Carlos Falgueras García
2016-08-18 16:17 ` Pablo Neira Ayuso

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).