>From 0bf2e1f418fc32715aabff0ae4683f7df916c651 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 2 Sep 2014 09:45:45 +1200 Subject: [PATCH 1/2] TODO uid_wrapper: Do not overflow the in variable (struct in_addr) by running inet_pton with ATTR_INET6 This needs to be first proposed and (if possible) tested in upstream nss_wrapper. Found by AddressSanitizer Change-Id: I6e3ad72c5dd1c6ae6b140cf7c9190c2e2a708e10 Signed-off-by: Andrew Bartlett --- lib/nss_wrapper/nss_wrapper.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/nss_wrapper/nss_wrapper.c b/lib/nss_wrapper/nss_wrapper.c index a012cbd..0cee478 100644 --- a/lib/nss_wrapper/nss_wrapper.c +++ b/lib/nss_wrapper/nss_wrapper.c @@ -3847,7 +3847,7 @@ static int nwrap_getaddrinfo(const char *node, bool is_addr_ipv6 = false; int eai = EAI_SYSTEM; int ret; - int rc; + int rc = 0; int af; if (node == NULL && service == NULL) { @@ -3901,16 +3901,12 @@ static int nwrap_getaddrinfo(const char *node, } af = hints->ai_family; - if (af == AF_UNSPEC) { - af = AF_INET; + if (af == AF_UNSPEC || af == AF_INET) { + rc = inet_pton(AF_INET, node, &in); } - rc = inet_pton(af, node, &in); if (rc == 1) { is_addr_ipv4 = true; - if (af == AF_UNSPEC) { - af = AF_INET; - } #ifdef HAVE_IPV6 } else { struct in6_addr in6; -- 2.1.0