]> git.ipfire.org Git - thirdparty/nftables.git/commit
parser_bison: Allow parens on RHS of relational_expr
authorPhil Sutter <phil@nwl.cc>
Mon, 28 Nov 2016 17:51:43 +0000 (18:51 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 29 Nov 2016 21:49:06 +0000 (22:49 +0100)
commit7222680eb328b5cebcea78b1dc6ccfacadeaa172
tree86e176b63816d0b9f0d702fb6398000e60f83309
parentffdcd3fd52f1e87eb99061ec1316f3e8e2f8a4d2
parser_bison: Allow parens on RHS of relational_expr

This is useful to allow a construct such as:

| tcp flags & (syn|fin) == (syn|fin)

Before, only the parentheses on the left side were allowed, but via a
quite funny path through the parser:

* expr might be a concat_expr
* concat_expr might be a basic_expr
* basic_expr is an inclusive_or_expr
* inclusive_or_expr might be an exclusive_or_expr
* exclusive_or_expr might be an and_expr
* and_expr might be 'and_expr AMPERSAND shift_expr'
  -> here we eliminate 'flags &' in above statement
* shift_expr might be a primary_expr
* primary_expr might be '( basic_expr )'

Commit a3e60492a684b ("parser: restrict relational rhs expression
recursion") introduced rhs_expr to disallow recursion on RHS, so just
reverting that change for relational_expr is a no go. Allowing rhs_expr
to be '( rhs_expr )' though seems way too intrusive to me since it's
being used in all kinds of places, so this patch is the safest way to
allow the above I could come up with.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/parser_bison.y