diff options
author | Florian Westphal <fw@strlen.de> | 2021-12-03 17:07:55 +0100 |
---|---|---|
committer | Florian Westphal <fw@strlen.de> | 2021-12-07 12:23:22 +0100 |
commit | 48aca2de80a7dd73f8f3a461c7f7ed47b6082766 (patch) | |
tree | 3ab36458bdef07e5d8c78ad364b77c21ffaad123 /src/ipopt.c | |
parent | 028856b3dd8c935bc53ff08434dce4728627a318 (diff) |
iptopt: fix crash with invalid field/type combo
% nft describe ip option rr value
segmentation fault
after this fix, this exits with 'Error: unknown ip option type/field'.
Problem is that 'rr' doesn't have a value template, so the template struct is
all-zeroes, so we crash when trying to use tmpl->dtype (its NULL).
Furthermore, expr_describe tries to print expr->identifier but expr is
exthdr, not symbol: ->identifier contains garbage.
Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'src/ipopt.c')
-rw-r--r-- | src/ipopt.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/ipopt.c b/src/ipopt.c index 42ea41cd..67e904ff 100644 --- a/src/ipopt.c +++ b/src/ipopt.c @@ -78,6 +78,9 @@ struct expr *ipopt_expr_alloc(const struct location *loc, uint8_t type, if (!tmpl) return NULL; + if (!tmpl->len) + return NULL; + expr = expr_alloc(loc, EXPR_EXTHDR, tmpl->dtype, BYTEORDER_BIG_ENDIAN, tmpl->len); expr->exthdr.desc = desc; |