diff mbox

[2/2] libxtables: xtables: Use getnameinfo()

Message ID 20161219233800.GB4610@salvia
State RFC
Delegated to: Pablo Neira
Headers show

Commit Message

Pablo Neira Ayuso Dec. 19, 2016, 11:38 p.m. UTC
On Mon, Dec 12, 2016 at 08:23:57PM +0530, Shyam Saini wrote:
> Replace gethostbyaddr() with getnameinfo() as getnameinfo()
> deprecates the former and allows programs to
> eliminate IPv4-versus-IPv6 dependencies

Also applied, thanks.

> Signed-off-by: Shyam Saini <mayhs11saini@gmail.com>
> ---
>  libxtables/xtables.c | 15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/libxtables/xtables.c b/libxtables/xtables.c
> index 6e75c15..e1512b1 100644
> --- a/libxtables/xtables.c
> +++ b/libxtables/xtables.c
> @@ -1210,13 +1210,18 @@ const char *xtables_ipaddr_to_numeric(const struct in_addr *addrp)
>  
>  static const char *ipaddr_to_host(const struct in_addr *addr)
>  {
> -	struct hostent *host;
> +	static char hostname[NI_MAXHOST];
> +	struct sockaddr_in saddr = { .sin_family = AF_INET, };
> +	saddr.sin_addr = *addr;

I collapsed this small update, so this is full C99 initialization.
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
diff mbox

Patch

diff --git a/libxtables/xtables.c b/libxtables/xtables.c
index bed43480d589..d43f97066ea9 100644
--- a/libxtables/xtables.c
+++ b/libxtables/xtables.c
@@ -1211,8 +1211,10 @@  const char *xtables_ipaddr_to_numeric(const
struct in_addr *addrp)
 static const char *ipaddr_to_host(const struct in_addr *addr)
 {
        static char hostname[NI_MAXHOST];
-       struct sockaddr_in saddr = { .sin_family = AF_INET, };
-       saddr.sin_addr = *addr;
+       struct sockaddr_in saddr = {
+               .sin_family = AF_INET,
+               .sin_addr = *addr,
+       };
        int err;