This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] getaddrinfo: return EAI_SERVICE when TCP or UDP port out of 1-65535 range
- From: Shawn Landden <shawn at churchofgit dot com>
- To: libc-alpha at sourceware dot org
- Cc: Shawn Landden <shawn at churchofgit dot com>
- Date: Wed, 4 Dec 2013 07:02:34 -0800
- Subject: [PATCH] getaddrinfo: return EAI_SERVICE when TCP or UDP port out of 1-65535 range
- Authentication-results: sourceware.org; auth=none
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