netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH libnftnl,v2 1/4] buffer: use nftnl_expr_snprintf() from nftnl_buf_expr()
Date: Wed,  4 Oct 2017 14:23:20 +0200	[thread overview]
Message-ID: <1507119803-15127-1-git-send-email-pablo@netfilter.org> (raw)

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>
---
 src/buffer.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/buffer.c b/src/buffer.c
index f9d5a838c4ab..9ec86af121c9 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
-- 
2.1.4


             reply	other threads:[~2017-10-04 12:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-04 12:23 Pablo Neira Ayuso [this message]
2017-10-04 12:23 ` [PATCH libnftnl,v2 2/4] expr: no need to nul-terminate buffer from expression ->snprintf indirection Pablo Neira Ayuso
2017-10-04 12:23 ` [PATCH libnftnl,v2 3/4] src: no need to nul-terminate buffer for nftnl_fprintf() calls Pablo Neira Ayuso
2017-10-04 12:23 ` [PATCH libnftnl,v2 4/4] src: do not nul-terminate internal helper functions Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1507119803-15127-1-git-send-email-pablo@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).