]> git.ipfire.org Git - thirdparty/libnftnl.git/commitdiff
nat: xml: fix wrong offset in snprintf
authorArturo Borrero <arturo.borrero.glez@gmail.com>
Sat, 15 Jun 2013 01:16:03 +0000 (03:16 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 17 Jun 2013 19:21:37 +0000 (21:21 +0200)
This patch fixes the buffer offset of the nat snprintf function
so elements are properly printed.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/expr/nat.c

index 1230d8e7f805319959556c6560ef449143161efe..6ccdd136783711c265b69920d59c1ff3b86952c1 100644 (file)
@@ -348,19 +348,21 @@ nft_rule_expr_nat_snprintf_xml(char *buf, size_t size,
                break;
        }
 
-       ret = snprintf(buf, len, "<family>%s</family>",
+       ret = snprintf(buf+offset, len, "<family>%s</family>",
                       nat->family == AF_INET ? "AF_INET" : "AF_INET6");
        SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
 
        if (e->flags & (1 << NFT_EXPR_NAT_REG_ADDR_MIN)) {
-               ret = snprintf(buf, len, "<sreg_addr_min_v4>%u</sreg_addr_min_v4>"
-                               " <sreg_addr_max_v4>%u</sreg_addr_max_v4> ",
+               ret = snprintf(buf+offset, len,
+                               "<sreg_addr_min_v4>%u</sreg_addr_min_v4>"
+                               "<sreg_addr_max_v4>%u</sreg_addr_max_v4>",
                               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, "<sreg_proto_min>%u</sreg_proto_min>"
+               ret = snprintf(buf+offset, len,
+                               "<sreg_proto_min>%u</sreg_proto_min>"
                                "<sreg_proto_max>%u</sreg_proto_max>",
                       nat->sreg_proto_min, nat->sreg_proto_max);
                SNPRINTF_BUFFER_SIZE(ret, size, len, offset);