netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH nft 1/7] segtree: perform stricter expression type validation from expr_value()
Date: Mon, 18 Apr 2016 20:14:29 +0200	[thread overview]
Message-ID: <1461003275-2330-2-git-send-email-pablo@netfilter.org> (raw)
In-Reply-To: <1461003275-2330-1-git-send-email-pablo@netfilter.org>

This helper function returns a expression value type that represents the
set element key. This functions currently expects two kind of
expressions: set elements and mappings.

Bail out otherwise, if we see anything else, we have to fix our code.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 src/segtree.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/segtree.c b/src/segtree.c
index 060951c..5b69ffb 100644
--- a/src/segtree.c
+++ b/src/segtree.c
@@ -473,10 +473,14 @@ extern void interval_map_decompose(struct expr *set);
 
 static struct expr *expr_value(struct expr *expr)
 {
-	if (expr->ops->type == EXPR_MAPPING)
+	switch (expr->ops->type) {
+	case EXPR_MAPPING:
 		return expr->left->key;
-	else
+	case EXPR_SET_ELEM:
 		return expr->key;
+	default:
+		BUG("invalid expression type %s\n", expr->ops->name);
+	}
 }
 
 static int expr_value_cmp(const void *p1, const void *p2)
-- 
2.1.4


  reply	other threads:[~2016-04-18 18:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-18 18:14 [PATCH nft 0/7] named sets with intervals Pablo Neira Ayuso
2016-04-18 18:14 ` Pablo Neira Ayuso [this message]
2016-04-18 18:14 ` [PATCH nft 2/7] segtree: clone full expression from interval_map_decompose() Pablo Neira Ayuso
2016-04-18 18:14 ` [PATCH nft 3/7] segtree: handle adjacent interval nodes from expr_value_cmp() Pablo Neira Ayuso
2016-04-18 18:14 ` [PATCH nft 4/7] segtree: explicit initialization via set_to_intervals() Pablo Neira Ayuso
2016-04-18 18:14 ` [PATCH nft 5/7] rule: support for incremental set interval element updates Pablo Neira Ayuso
2016-04-18 18:14 ` [PATCH nft 6/7] segtree: special handling for the first non-matching segment Pablo Neira Ayuso
2016-04-18 18:14 ` [PATCH nft 7/7] evaluate: bail out on prefix or range to non-interval set Pablo Neira Ayuso

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=1461003275-2330-2-git-send-email-pablo@netfilter.org \
    --to=pablo@netfilter.org \
    --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).