]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
xtables: fix excessive memory allocation in host_to_ipaddr
authorWes Campaigne <westacular@gmail.com>
Tue, 22 Feb 2011 00:10:11 +0000 (19:10 -0500)
committerJan Engelhardt <jengelh@medozas.de>
Sat, 26 Feb 2011 22:48:40 +0000 (23:48 +0100)
host_to_ipaddr was unnecessarily asking for an array of length n^2 to
store just n addresses.

Signed-off-by: Wes Campaigne <westacular@gmail.com>
xtables.c

index 83c5b41f5d47ff98dd66430ca80e3a3ba2c0f00e..b45bf928fd49474a8948f6950157d20a3ca3d75a 100644 (file)
--- a/xtables.c
+++ b/xtables.c
@@ -1143,7 +1143,7 @@ static struct in_addr *host_to_ipaddr(const char *name, unsigned int *naddr)
 
                while (host->h_addr_list[*naddr] != NULL)
                        ++*naddr;
-               addr = xtables_calloc(*naddr, sizeof(struct in_addr) * *naddr);
+               addr = xtables_calloc(*naddr, sizeof(struct in_addr));
                for (i = 0; i < *naddr; i++)
                        memcpy(&addr[i], host->h_addr_list[i],
                               sizeof(struct in_addr));