From: Florian Westphal Date: Fri, 15 Dec 2023 12:04:22 +0000 (+0100) Subject: tcpopt: don't create exthdr expression without datatype X-Git-Tag: v1.0.6.1~268 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a077b34b6b315d82d4b3c9b5e326c73b86f3b60c;p=thirdparty%2Fnftables.git tcpopt: don't create exthdr expression without datatype commit c9f934ca446de5041ce6f19e4ee6a0c74b120186 upstream. The reproducer crashes during concat evaluation, as the exthdr expression lacks a datatype. This should never happen, i->dtype must be set. In this case the culprit is tcp option parsing, it will wire up a non-existent template, because the "nop" option has no length field (1 byte only). Signed-off-by: Florian Westphal --- diff --git a/src/tcpopt.c b/src/tcpopt.c index 7c458597..179a262c 100644 --- a/src/tcpopt.c +++ b/src/tcpopt.c @@ -225,7 +225,7 @@ struct expr *tcpopt_expr_alloc(const struct location *loc, } tmpl = &desc->templates[field]; - if (!tmpl) + if (!tmpl || !tmpl->dtype) return NULL; expr = expr_alloc(loc, EXPR_EXTHDR, tmpl->dtype, diff --git a/tests/shell/testcases/bogons/nft-f/tcp_option_without_template b/tests/shell/testcases/bogons/nft-f/tcp_option_without_template new file mode 100644 index 00000000..fd732fd3 --- /dev/null +++ b/tests/shell/testcases/bogons/nft-f/tcp_option_without_template @@ -0,0 +1 @@ +add rule f i tcp option nop length . @ih,32,3 1