tcpopt: bogus assertion on undefined options
Pablo Neira Ayuso
maintainerPATCH 1/1 tcpopt: bogus assertion on undefined options
# nft add rule x y tcp option 6 exists # nft list ruleset nft: tcpopt.c:208: tcpopt_init_raw: Assertion `expr->exthdr.desc != NULL' failed. Aborted
Signed-off-by Pablo Neira Ayuso <[email protected]>
--- src/tcpopt.c | 3 ++- tests/py/any/tcpopt.t | 1 + tests/py/any/tcpopt.t.json | 17 +++++++++++++++++ tests/py/any/tcpopt.t.payload | 5 +++++ 4 files changed, 25 insertions(+), 1 deletion(-)
src/tcpopt.c +2 -1
@@ -200,7 +200,8 @@ void tcpopt_init_raw(struct expr *expr, uint8_t type, unsigned int off,else datatype_set (expr, &integer_type); -if (type >=array_size (tcpopt_protocols)) +if (type >=array_size (tcpopt_protocols) || + !tcpopt_protocols[type])return ; expr->exthdr.desc = tcpopt_protocols[type];
tests/py/any/tcpopt.t +1 -0
@@ -31,6 +31,7 @@ tcp option timestamp length 1;ok tcp option timestamp tsval 1;ok tcp option timestamp tsecr 1;ok tcp option 255 missing;ok +tcp option 6 exists;ok tcp option @255,8,8 255;ok tcp option foobar;fail
tests/py/any/tcpopt.t.json +17 -0
@@ -414,6 +414,23 @@ } ] +# tcp option 6 exists +[ + { + "match": { + "left": { + "tcp option": { + "base": 6, + "len": 8, + "offset": 0 + } + }, + "op": "==", + "right": true + } + } +] + # tcp option 255 missing [ {
tests/py/any/tcpopt.t.payload +5 -0
@@ -133,6 +133,11 @@ inet [ exthdr load tcpopt 1b @ 255 + 0 present => reg 1 ] [ cmp eq reg 1 0x00000000 ] +# tcp option 6 exists +inet + [ exthdr load tcpopt 1b @ 6 + 0 present => reg 1 ] + [ cmp eq reg 1 0x00000001 ] + # tcp option @255,8,8 255 inet [ exthdr load tcpopt 1b @ 255 + 1 => reg 1 ]
Signature · 1 line
2.20.1