Patchwork [libnftables,2/5] rule: fix snprintf return value

login
register
mail settings
Submitter Arturo Borrero
Date June 3, 2013, 8:44 p.m.
Message ID <20130603204452.27713.79515.stgit@nfdev.cica.es>
Download mbox | patch
Permalink /patch/248413/
State Accepted
Headers show

Comments

Arturo Borrero - June 3, 2013, 8:44 p.m.
This cause some chained snprintf to fail.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
---
 src/rule.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Pablo Neira - June 5, 2013, 3:09 a.m.
On Mon, Jun 03, 2013 at 10:44:52PM +0200, Arturo Borrero wrote:
> This cause some chained snprintf to fail.

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/src/rule.c b/src/rule.c
index f0208d9..a91d21d 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -676,7 +676,7 @@  static int nft_rule_snprintf_xml(char *buf, size_t size, struct nft_rule *r,
 	ret = snprintf(buf+offset, len, "</rule>");
 	SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
 
-	return ret;
+	return offset;
 }
 
 static int nft_rule_snprintf_default(char *buf, size_t size, struct nft_rule *r, 
@@ -699,7 +699,7 @@  static int nft_rule_snprintf_default(char *buf, size_t size, struct nft_rule *r,
 		SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
 	}
 
-	return ret;
+	return offset;
 }
 
 int nft_rule_snprintf(char *buf, size_t size, struct nft_rule *r,