summaryrefslogtreecommitdiffstats
path: root/src/expr/dynset.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2016-05-05 14:05:56 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2016-05-05 14:11:44 +0200
commit813da08a8bd9d320d6a6a52b3cacc87b8d0ed1f9 (patch)
tree45c2296726738e306980391d9c800545fa9c99a5 /src/expr/dynset.c
parentde67d7727181602224a4fb9943deab073c5f860c (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/dynset.c')
-rw-r--r--src/expr/dynset.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/expr/dynset.c b/src/expr/dynset.c
index ec8f2d3..e82b10b 100644
--- a/src/expr/dynset.c
+++ b/src/expr/dynset.c
@@ -22,17 +22,13 @@
#include "expr_ops.h"
#include <buffer.h>
-#ifndef IFNAMSIZ
-#define IFNAMSIZ 16
-#endif
-
struct nftnl_expr_dynset {
enum nft_registers sreg_key;
enum nft_registers sreg_data;
enum nft_dynset_ops op;
uint64_t timeout;
struct nftnl_expr *expr;
- char set_name[IFNAMSIZ];
+ char *set_name;
uint32_t set_id;
};
@@ -56,8 +52,7 @@ nftnl_expr_dynset_set(struct nftnl_expr *e, uint16_t type,
dynset->timeout = *((uint64_t *)data);
break;
case NFTNL_EXPR_DYNSET_SET_NAME:
- snprintf(dynset->set_name, sizeof(dynset->set_name), "%s",
- (const char *)data);
+ dynset->set_name = strdup((const char *)data);
break;
case NFTNL_EXPR_DYNSET_SET_ID:
dynset->set_id = *((uint32_t *)data);
@@ -186,7 +181,8 @@ nftnl_expr_dynset_parse(struct nftnl_expr *e, struct nlattr *attr)
e->flags |= (1 << NFTNL_EXPR_DYNSET_TIMEOUT);
}
if (tb[NFTA_DYNSET_SET_NAME]) {
- strcpy(dynset->set_name, mnl_attr_get_str(tb[NFTA_DYNSET_SET_NAME]));
+ dynset->set_name =
+ strdup(mnl_attr_get_str(tb[NFTA_DYNSET_SET_NAME]));
e->flags |= (1 << NFTNL_EXPR_DYNSET_SET_NAME);
}
if (tb[NFTA_DYNSET_SET_ID]) {
@@ -361,10 +357,18 @@ nftnl_expr_dynset_snprintf(char *buf, size_t size, uint32_t type,
return -1;
}
+static void nftnl_expr_dynset_free(struct nftnl_expr *e)
+{
+ struct nftnl_expr_dynset *dynset = nftnl_expr_data(e);
+
+ xfree(dynset->set_name);
+}
+
struct expr_ops expr_ops_dynset = {
.name = "dynset",
.alloc_len = sizeof(struct nftnl_expr_dynset),
.max_attr = NFTA_DYNSET_MAX,
+ .free = nftnl_expr_dynset_free,
.set = nftnl_expr_dynset_set,
.get = nftnl_expr_dynset_get,
.parse = nftnl_expr_dynset_parse,