Patchwork [libnftables,19/21] nat: snprintf: fix buffer offset

login
register
mail settings
Submitter Arturo Borrero
Date June 26, 2013, 11:37 a.m.
Message ID <20130626113719.23511.1621.stgit@nfdev.cica.es>
Download mbox | patch
Permalink /patch/254717/
State Accepted
Headers show

Comments

Arturo Borrero - June 26, 2013, 11:37 a.m.
This patch fix the buffer offset necesary to print correctly the nat expr in a default output mode.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
---
 src/expr/nat.c |    6 +++---
 1 file changed, 3 insertions(+), 3 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

Patch

diff --git a/src/expr/nat.c b/src/expr/nat.c
index 7d83154..378d053 100644
--- a/src/expr/nat.c
+++ b/src/expr/nat.c
@@ -383,18 +383,18 @@  nft_rule_expr_nat_snprintf_default(char *buf, size_t size,
 		break;
 	}
 
-	ret = snprintf(buf, len, "family=%s ", nft_family2str(nat->family));
+	ret = snprintf(buf+offset, len, "family=%s ", nft_family2str(nat->family));
 	SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
 
 	if (e->flags & (1 << NFT_EXPR_NAT_REG_ADDR_MIN)) {
-		ret = snprintf(buf, len,
+		ret = snprintf(buf+offset, len,
 			       "sreg_addr_min_v4=%u sreg_addr_max_v4=%u ",
 			       nat->sreg_addr_min, nat->sreg_addr_max);
 		SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
 	}
 
 	if (e->flags & (1 << NFT_EXPR_NAT_REG_PROTO_MIN)) {
-		ret = snprintf(buf, len,
+		ret = snprintf(buf+offset, len,
 			       "sreg_proto_min=%u sreg_proto_max=%u ",
 			       nat->sreg_proto_min, nat->sreg_proto_max);
 		SNPRINTF_BUFFER_SIZE(ret, size, len, offset);