summaryrefslogtreecommitdiffstats
path: root/src/rule.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2014-09-16 11:03:57 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2014-09-17 10:17:38 +0200
commit55ee009aaa650553868509081f2e2c5e2915008c (patch)
treed9217f803b7b801f063b0f1204f7eab55bbbee9f /src/rule.c
parent102c30013e622a9ffdccace52dee2552b06e5d3d (diff)
src: fix 'describe' command when passing wrong expressions
Before this patch: # nft describe tcp foo value expression, datatype inet_proto (Internet protocol) (basetype integer), 8 bits Segmentation fault After this patch: # nft describe tcp foo <cmdline>:1:14-16: Error: syntax error, unexpected string, expecting end of file or newline or semicolon describe tcp foo ^^^ Reported-by: Kevin Fenzi <kevin@scrye.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/rule.c')
-rw-r--r--src/rule.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/rule.c b/src/rule.c
index cb2a2285..80deb1b9 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -548,6 +548,9 @@ void cmd_free(struct cmd *cmd)
case CMD_OBJ_TABLE:
table_free(cmd->table);
break;
+ case CMD_OBJ_EXPR:
+ expr_free(cmd->expr);
+ break;
default:
BUG("invalid command object type %u\n", cmd->obj);
}
@@ -909,6 +912,12 @@ static int do_command_monitor(struct netlink_ctx *ctx, struct cmd *cmd)
return netlink_monitor(&monhandler);
}
+static int do_command_describe(struct netlink_ctx *ctx, struct cmd *cmd)
+{
+ expr_describe(cmd->expr);
+ return 0;
+}
+
int do_command(struct netlink_ctx *ctx, struct cmd *cmd)
{
switch (cmd->op) {
@@ -930,6 +939,8 @@ int do_command(struct netlink_ctx *ctx, struct cmd *cmd)
return do_command_export(ctx, cmd);
case CMD_MONITOR:
return do_command_monitor(ctx, cmd);
+ case CMD_DESCRIBE:
+ return do_command_describe(ctx, cmd);
default:
BUG("invalid command object type %u\n", cmd->obj);
}