netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Florian Westphal <fw@strlen.de>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nft] evaluate: tolerate empty concatenation
Date: Thu, 27 Mar 2025 16:40:38 +0100	[thread overview]
Message-ID: <Z-VxdrgTRO1RTdBq@calendula> (raw)
In-Reply-To: <Z-Vv1R-OmC2QukpS@calendula>

[-- Attachment #1: Type: text/plain, Size: 860 bytes --]

On Thu, Mar 27, 2025 at 04:33:59PM +0100, Pablo Neira Ayuso wrote:
> Hi Florian,
> 
> On Mon, Mar 24, 2025 at 12:52:58PM +0100, Florian Westphal wrote:
> > Don't rely on a successful evaluation of set->key.
> > With this input, set->key fails validation but subsequent
> > element evaluation asserts because the context points at
> > the set key -- an empty concatenation.
> > 
> > Causes:
> > nft: src/evaluate.c:1681: expr_evaluate_concat: Assertion `!list_empty(&ctx->ectx.key->expressions)' failed.
> > 
> > After patch:
> > internal:0:0-0: Error: unqualified type  specified in set definition. Try "typeof expression" instead of "type datatype".
> > internal:0:0-0: Error: Could not parse symbolic invalid expression
> 
> Maybe block this from the json parser itself?

Maybe this instead? This covers for empty concatenation in both set
key and set data.

[-- Attachment #2: x.patch --]
[-- Type: text/x-diff, Size: 752 bytes --]

commit e0123be7a908d1a4b7c43d0817b9ecccf2bd1416
Author: Pablo Neira Ayuso <pablo@netfilter.org>
Date:   Thu Mar 27 16:32:16 2025 +0100

    parser_json: reject empty concatention in set key and data
    
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>

diff --git a/src/parser_json.c b/src/parser_json.c
index 17bc38b565ae..513e0b10f028 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -1729,6 +1729,13 @@ static struct expr *json_parse_dtype_expr(struct json_ctx *ctx, json_t *root)
 			}
 			compound_expr_add(expr, i);
 		}
+
+		if (list_empty(&expr->expressions)) {
+			json_error(ctx, "Empty concatenation");
+			expr_free(expr);
+			return NULL;
+		}
+
 		return expr;
 	} else if (json_is_object(root)) {
 		const char *key;

  reply	other threads:[~2025-03-27 15:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-24 11:52 [PATCH nft] evaluate: tolerate empty concatenation Florian Westphal
2025-03-27 15:33 ` Pablo Neira Ayuso
2025-03-27 15:40   ` Pablo Neira Ayuso [this message]
2025-03-27 15:49     ` Florian Westphal
2025-03-27 15:52       ` Pablo Neira Ayuso
2025-03-27 15:55         ` Florian Westphal

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=Z-VxdrgTRO1RTdBq@calendula \
    --to=pablo@netfilter.org \
    --cc=fw@strlen.de \
    --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).