evaluate: reject sets with no key
Florian Westphal
maintainerPATCH 1/1 evaluate: reject sets with no key
nft --check -f tests/shell/testcases/bogons/nft-f/set_without_key Segmentation fault (core dumped)
Fixes 56c90a2dd2eb ("evaluate: expand sets and maps before evaluation")
Signed-off-by Florian Westphal <[email protected]>
--- src/evaluate.c | 3 +++ tests/shell/testcases/bogons/nft-f/map_without_key | 5 +++++ tests/shell/testcases/bogons/nft-f/set_without_key | 5 +++++ 3 files changed, 13 insertions(+) create mode 100644 tests/shell/testcases/bogons/nft-f/map_without_key create mode 100644 tests/shell/testcases/bogons/nft-f/set_without_key
src/evaluate.c +3 -0
@@ -4621,6 +4621,9 @@ static int elems_evaluate(struct eval_ctx *ctx, struct set *set) { ctx->set = set;if (set->init !=NULL ) { +if (set->key ==NULL ) +return set_error (ctx, set,"set definition does not specify key" ); +__expr_set_context (&ctx->ectx, set->key->dtype, set->key->byteorder, set->key->len,0 );if (expr_evaluate (ctx, &set->init) <0 )
tests/shell/testcases/bogons/nft-f/map_without_key new file +5 -0
@@ -0,0 +1,5 @@ +table t { + map m { + elements = { 0x00000023 : 0x00001337 } + } +}
tests/shell/testcases/bogons/nft-f/set_without_key new file +5 -0
@@ -0,0 +1,5 @@ +table ip t { + set s { + elements = { 0x00000023-0x00000142, 0x00001337 } + } +}
Signature · 1 line
2.41.0