summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2014-07-28 00:07:37 -0400
committerRich Felker <dalias@aerifal.cx>2014-07-28 00:07:37 -0400
commitbf9d9ceaa3295847d901821c62f5f6f23db7aefd (patch)
tree5684588ed9a59ffbc48d018aa2f849e7132ee3f5
parent30bd499ae1f62e9d2fad4282d42057083709e0eb (diff)
downloadmusl-bf9d9ceaa3295847d901821c62f5f6f23db7aefd.tar.gz
fix gethostby*_r result pointer value on error
according to the documentation in the man pages, the GNU extension functions gethostbyaddr_r, gethostbyname_r and gethostbyname2_r are guaranteed to set the result pointer to NULL in case of error or no result. corresponds to commit fe82bb9b921be34370e6b71a1c6f062c20999ae0 in master branch.
-rw-r--r--src/network/gethostbyaddr_r.c2
-rw-r--r--src/network/gethostbyname2_r.c2
2 files changed, 4 insertions, 0 deletions
diff --git a/src/network/gethostbyaddr_r.c b/src/network/gethostbyaddr_r.c
index 73e76447..66e03309 100644
--- a/src/network/gethostbyaddr_r.c
+++ b/src/network/gethostbyaddr_r.c
@@ -18,6 +18,8 @@ int gethostbyaddr_r(const void *a, socklen_t l, int af,
socklen_t sl = af==AF_INET6 ? sizeof sa.sin6 : sizeof sa.sin;
int i;
+ *res = 0;
+
/* Load address argument into sockaddr structure */
if (af==AF_INET6 && l==16) memcpy(&sa.sin6.sin6_addr, a, 16);
else if (af==AF_INET && l==4) memcpy(&sa.sin.sin_addr, a, 4);
diff --git a/src/network/gethostbyname2_r.c b/src/network/gethostbyname2_r.c
index 27eb080f..d6920b26 100644
--- a/src/network/gethostbyname2_r.c
+++ b/src/network/gethostbyname2_r.c
@@ -20,6 +20,8 @@ int gethostbyname2_r(const char *name, int af,
size_t need;
const char *canon;
+ *res = 0;
+
af = hint.ai_family;
/* Align buffer */