summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2017-10-04 13:24:02 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2017-10-04 14:06:35 +0200
commit1876b4646ac04c1f57348b1e6601275b699cac67 (patch)
tree6c138159a4c5f413fc463a2bc5220f415feeaae5
parent72386012200a96f9bb721ab4ddb5a9325c68c5f7 (diff)
buffer: use nftnl_expr_snprintf() from nftnl_buf_expr()
This helper function deals with no ->snprintf() indirection in expression and safe buffer nul-termination, use it. Fixes: 059b9bf6fb31 ("src: Use nftnl_buf to export XML/JSON rules") Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r--src/buffer.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/buffer.c b/src/buffer.c
index f9d5a83..9ec86af 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -14,6 +14,7 @@
#include <string.h>
#include <buffer.h>
#include <libnftnl/common.h>
+#include <libnftnl/expr.h>
#include "internal.h"
int nftnl_buf_update(struct nftnl_buf *b, int ret)
@@ -206,8 +207,8 @@ int nftnl_buf_expr(struct nftnl_buf *b, int type, uint32_t flags,
case NFTNL_OUTPUT_JSON:
nftnl_buf_put(b, "{");
nftnl_buf_str(b, type, expr->ops->name, TYPE);
- ret = expr->ops->snprintf(b->buf + b->off, b->len, type, flags,
- expr);
+ ret = nftnl_expr_snprintf(b->buf + b->off, b->len, expr, type,
+ flags);
if (ret > 0)
nftnl_buf_update(b, ret);
else