diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2016-05-05 14:05:56 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2016-05-05 14:11:44 +0200 |
commit | 813da08a8bd9d320d6a6a52b3cacc87b8d0ed1f9 (patch) | |
tree | 45c2296726738e306980391d9c800545fa9c99a5 /src/expr/lookup.c | |
parent | de67d7727181602224a4fb9943deab073c5f860c (diff) |
libnftnl: allow any set name length
Unfortunately libnftnl restricts the set names in the lookup and dynset
expressions to 16 bytes. Remove this restriction so this can work with
the upcoming 4.7 Linux kernel.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/expr/lookup.c')
-rw-r--r-- | src/expr/lookup.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/expr/lookup.c b/src/expr/lookup.c index d911cb6..b26d9e5 100644 --- a/src/expr/lookup.c +++ b/src/expr/lookup.c @@ -21,14 +21,10 @@ #include <libnftnl/rule.h> #include <libnftnl/expr.h> -#ifndef IFNAMSIZ -#define IFNAMSIZ 16 -#endif - struct nftnl_expr_lookup { enum nft_registers sreg; enum nft_registers dreg; - char set_name[IFNAMSIZ]; + char *set_name; uint32_t set_id; }; @@ -46,8 +42,7 @@ nftnl_expr_lookup_set(struct nftnl_expr *e, uint16_t type, lookup->dreg = *((uint32_t *)data); break; case NFTNL_EXPR_LOOKUP_SET: - snprintf(lookup->set_name, sizeof(lookup->set_name), "%s", - (const char *)data); + lookup->set_name = strdup((const char *)data); break; case NFTNL_EXPR_LOOKUP_SET_ID: lookup->set_id = *((uint32_t *)data); @@ -140,7 +135,8 @@ nftnl_expr_lookup_parse(struct nftnl_expr *e, struct nlattr *attr) e->flags |= (1 << NFTNL_EXPR_LOOKUP_DREG); } if (tb[NFTA_LOOKUP_SET]) { - strcpy(lookup->set_name, mnl_attr_get_str(tb[NFTA_LOOKUP_SET])); + lookup->set_name = + strdup(mnl_attr_get_str(tb[NFTA_LOOKUP_SET])); e->flags |= (1 << NFTNL_EXPR_LOOKUP_SET); } if (tb[NFTA_LOOKUP_SET_ID]) { @@ -258,10 +254,18 @@ nftnl_expr_lookup_snprintf(char *buf, size_t size, uint32_t type, return -1; } +static void nftnl_expr_lookup_free(struct nftnl_expr *e) +{ + struct nftnl_expr_lookup *lookup = nftnl_expr_data(e); + + xfree(lookup->set_name); +} + struct expr_ops expr_ops_lookup = { .name = "lookup", .alloc_len = sizeof(struct nftnl_expr_lookup), .max_attr = NFTA_LOOKUP_MAX, + .free = nftnl_expr_lookup_free, .set = nftnl_expr_lookup_set, .get = nftnl_expr_lookup_get, .parse = nftnl_expr_lookup_parse, |