summaryrefslogtreecommitdiff
path: root/libc/inet/getaddrinfo.c
diff options
context:
space:
mode:
authorCarmelo Amoroso <carmelo.amoroso@st.com>2008-02-07 16:17:14 +0000
committerCarmelo Amoroso <carmelo.amoroso@st.com>2008-02-07 16:17:14 +0000
commit0a595705ecbcf9fc3677459436d3deabfa5b115f (patch)
tree3f31f0092349aa9d6b6d8fb5102a9b09cbe5cf97 /libc/inet/getaddrinfo.c
parentfac054e086ae3d1cc1024093c68962207bcb9c34 (diff)
Added AI_NUMERICSERV flag and check if the string is not just a number
when AI_NUMERICSERV flag set. Signed-off-by: Filippo Arcidiacono <filippo.arcidiacono@st.com>
Diffstat (limited to 'libc/inet/getaddrinfo.c')
-rw-r--r--libc/inet/getaddrinfo.c8
1 files changed, 6 insertions, 2 deletions
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