summaryrefslogtreecommitdiffstats
path: root/src/datatype.c
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2013-04-22 18:50:44 +0200
committerPatrick McHardy <kaber@trash.net>2013-04-22 18:50:44 +0200
commit2e27ad8122fe20db802e1c7bb9d5f4ad6cd23665 (patch)
tree0ee3533c6a45d1f00226eaea77255033f297c727 /src/datatype.c
parente1538f3e32a440fd8896cec073a3182d09f6b9b0 (diff)
expr: catch missing and excess elements in concatenations
# nft -nn filter output ip daddr . tcp dport . tcp dport { 192.168.0.1 . ssh } <cmdline>:1:50-66: Error: datatype mismatch, expected concatenation of (IPv4 address, internet network service, internet network service), expression has type concatenation of (IPv4 address, internet network service) filter output ip daddr . tcp dport . tcp dport { 192.168.0.1 . ssh } ^^^^^^^^^^^^^^^^^ # nft -nn filter output ip daddr . tcp dport . tcp dport { 192.168.0.1 . ssh . ssh . ssh} <cmdline>:1:76-78: Error: unexpected concat component, expecting concatenation of (IPv4 address, internet network service, internet network service) filter output ip daddr . tcp dport . tcp dport { 192.168.0.1 . ssh . ssh . ssh} ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^ Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'src/datatype.c')
-rw-r--r--src/datatype.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/datatype.c b/src/datatype.c
index 3c17e929..2cb937f5 100644
--- a/src/datatype.c
+++ b/src/datatype.c
@@ -662,20 +662,23 @@ const struct datatype *concat_type_alloc(const struct expr *expr)
{
struct datatype *dtype;
struct expr *i;
- char desc[256] = "concatenation of ";
- unsigned int type = 0;
+ char desc[256] = "concatenation of (";
+ unsigned int type = 0, size = 0;
list_for_each_entry(i, &expr->expressions, list) {
- if (type != 0)
+ if (size != 0)
strncat(desc, ", ", sizeof(desc) - strlen(desc) - 1);
strncat(desc, i->dtype->desc, sizeof(desc) - strlen(desc) - 1);
type <<= 8;
type |= i->dtype->type;
+ size++;
}
+ strncat(desc, ")", sizeof(desc) - strlen(desc) - 1);
dtype = xzalloc(sizeof(*dtype));
dtype->type = type;
+ dtype->size = size;
dtype->desc = xstrdup(desc);
dtype->parse = concat_type_parse;