From 0a595705ecbcf9fc3677459436d3deabfa5b115f Mon Sep 17 00:00:00 2001 From: Carmelo Amoroso Date: Thu, 7 Feb 2008 16:17:14 +0000 Subject: Added AI_NUMERICSERV flag and check if the string is not just a number when AI_NUMERICSERV flag set. Signed-off-by: Filippo Arcidiacono --- libc/inet/getaddrinfo.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'libc') diff --git a/libc/inet/getaddrinfo.c b/libc/inet/getaddrinfo.c index 1c593fc4f..5395830b4 100644 --- a/libc/inet/getaddrinfo.c +++ b/libc/inet/getaddrinfo.c @@ -823,7 +823,7 @@ getaddrinfo (const char *name, const char *service, hints = &default_hints; if (hints->ai_flags & ~(AI_PASSIVE|AI_CANONNAME|AI_NUMERICHOST| - AI_ADDRCONFIG|AI_V4MAPPED|AI_ALL)) + AI_ADDRCONFIG|AI_V4MAPPED|AI_NUMERICSERV|AI_ALL)) return EAI_BADFLAGS; if ((hints->ai_flags & AI_CANONNAME) && name == NULL) @@ -834,8 +834,12 @@ getaddrinfo (const char *name, const char *service, char *c; gaih_service.name = service; gaih_service.num = strtoul (gaih_service.name, &c, 10); - if (*c) + if (*c != '\0') { + if (hints->ai_flags & AI_NUMERICSERV) + return EAI_NONAME; + gaih_service.num = -1; + } else /* * Can't specify a numerical socket unless a protocol -- cgit v1.2.3