[PATCH] getaddrinfo: return EAI_SERVICE when TCP or UDP port out of 1-65535 range
Shawn Landden
shawn@churchofgit.com
Wed Dec 4 15:24:00 GMT 2013
Reported-by: Martin Pool <mbp@sourcefrog.net>
Signed-off-by: Shawn Landden <shawn@churchofgit.com>
---
sysdeps/posix/getaddrinfo.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 8218237..5b3b10d 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -2391,6 +2391,12 @@ getaddrinfo (const char *name, const char *service,
gaih_service.num = -1;
}
+ else if ((hints->ai_family == AF_INET || hints->ai_family == AF_INET6)
+ && (hints->ai_socktype == SOCK_STREAM || hints->ai_socktype == SOCK_DGRAM)
+ && (gaih_service.num == 0 || gaih_service.num > 65535))
+ {
+ return EAI_SERVICE;
+ }
pservice = &gaih_service;
}
--
1.8.5
More information about the Libc-alpha
mailing list