diff mbox

[libnftnl] rule: Fix comparison between rules

Message ID 20160818151236.19924-1-carlosfg@riseup.net
State Accepted
Delegated to: Pablo Neira
Headers show

Commit Message

Carlos Falgueras García Aug. 18, 2016, 3:12 p.m. UTC
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(+)

Comments

Pablo Neira Ayuso Aug. 18, 2016, 4:17 p.m. UTC | #1
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.
--
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
diff mbox

Patch

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;
 }