This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] getaddrinfo: return EAI_SERVICE when TCP or UDP port out of 1-65535 range


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]