From: Florian Westphal <fw@strlen.de>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Florian Westphal <fw@strlen.de>, netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nft] expression: don't try to import empty string
Date: Mon, 31 Mar 2025 14:37:15 +0200 [thread overview]
Message-ID: <20250331123715.GA12883@breakpoint.cc> (raw)
In-Reply-To: <Z-p7BmD6RqC9-IN4@calendula>
Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> Hi Florian,
>
> On Thu, Mar 27, 2025 at 04:17:11PM +0100, Florian Westphal wrote:
> > The bogon will trigger the assertion in mpz_import_data:
> > src/expression.c:418: constant_expr_alloc: Assertion `(((len) + (8) - 1) / (8)) > 0' failed.
>
> I took a quick look searching for {s:s} in src/parser_json.c
>
> The common idiom is json_parse_err() then a helper parser function to
> validate the string.
>
> It seems it is missing in this case. Maybe tigthen json parser instead?
>
> Caller invoking constant_expr_alloc() with data != NULL but no len
> looks broken to me.
return constant_expr_alloc(int_loc, &string_type, BYTEORDER_HOST_ENDIAN,
strlen(chain) * BITS_PER_BYTE, chain);
chain name is '""'.
There are other spots where we possibly call into constant_expr_alloc()
with a 0 argument.
I think it would be a lot more work and bloat to add all the checks on
the json side while its a one-liner in constant_expr_alloc().
I could also add json_constant_expr_alloc() but it seems kinda silly to me.
next prev parent reply other threads:[~2025-03-31 12:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-27 15:17 [PATCH nft] expression: don't try to import empty string Florian Westphal
2025-03-31 11:22 ` Pablo Neira Ayuso
2025-03-31 12:37 ` Florian Westphal [this message]
2025-03-31 16:10 ` 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=20250331123715.GA12883@breakpoint.cc \
--to=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.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).