about summary refs log tree commit diff
path: root/src/network/getaddrinfo.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2013-11-27 00:54:03 -0500
committerRich Felker <dalias@aerifal.cx>2013-11-27 00:54:03 -0500
commitcabe9aa974aca34c0fda91028c770dee96ba51dc (patch)
treeb42c3cad3efd6a219047a676ebf9dcaf2008cc1b /src/network/getaddrinfo.c
parenta663c930196b50194921e7ee685d0704ac32f6f4 (diff)
downloadmusl-cabe9aa974aca34c0fda91028c770dee96ba51dc.tar.gz
musl-cabe9aa974aca34c0fda91028c770dee96ba51dc.tar.xz
musl-cabe9aa974aca34c0fda91028c770dee96ba51dc.zip
reject invalid address families in getaddrinfo
subsequent code assumes the address family requested is either
unspecified or one of IPv4/IPv6, and could malfunction if this
constraint is not met, so other address families should be explicitly
rejected.
Diffstat (limited to 'src/network/getaddrinfo.c')
-rw-r--r--src/network/getaddrinfo.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/network/getaddrinfo.c b/src/network/getaddrinfo.c
index e58db6cf..5d45be74 100644
--- a/src/network/getaddrinfo.c
+++ b/src/network/getaddrinfo.c
@@ -62,6 +62,9 @@ int getaddrinfo(const char *restrict host, const char *restrict serv, const stru
 	int result;
 	int cnt;
 
+	if (family != AF_INET && family != AF_INET6 && family != AF_UNSPEC)
+		return EAI_FAMILY;
+
 	if (host && strlen(host)>255) return EAI_NONAME;
 	if (serv && strlen(serv)>32) return EAI_SERVICE;