[PATCH iptables] libxtables: fix wrong naddr when using localhost

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



$ iptables-translate -A INPUT -p tcp -s localhost --dport 8000 -j ACCEPT

gives

 nft add rule ip filter INPUT ip saddr 127.0.0.1 tcp dport 8000 counter accept
 add rule ip filter INPUT ip saddr 127.0.0.1 tcp dport 8000 counter accept

with this patch we get

 nft add rule ip filter INPUT ip saddr 127.0.0.1 tcp dport 8000 counter accept

Signed-off-by: Alexander Alemayhu <alexander@xxxxxxxxxxxx>
---
 libxtables/xtables.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libxtables/xtables.c b/libxtables/xtables.c
index d43f97066ea9..defc57414de3 100644
--- a/libxtables/xtables.c
+++ b/libxtables/xtables.c
@@ -1376,7 +1376,7 @@ static struct in_addr *host_to_ipaddr(const char *name, unsigned int *naddr)
 		return NULL;
 	} else {
 		for (p = res; p != NULL; p = p->ai_next)
-			++*naddr;
+			*naddr++;
 		addr = xtables_calloc(*naddr, sizeof(struct in_addr));
 		for (i = 0, p = res; p != NULL; p = p->ai_next)
 			memcpy(&addr[i++],
-- 
2.9.3

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



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux