diff options
Diffstat (limited to 'ext/socket')
-rw-r--r-- | ext/socket/addrinfo.h | 4 | ||||
-rw-r--r-- | ext/socket/getaddrinfo.c | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/ext/socket/addrinfo.h b/ext/socket/addrinfo.h index f6061f1e26..171d3c2ce7 100644 --- a/ext/socket/addrinfo.h +++ b/ext/socket/addrinfo.h @@ -50,6 +50,7 @@ #undef AI_PASSIVE #undef AI_CANONNAME #undef AI_NUMERICHOST +#undef AI_NUMERICSERV #undef AI_ALL #undef AI_ADDRCONFIG #undef AI_V4MAPPED @@ -107,9 +108,10 @@ #define AI_PASSIVE 0x00000001 /* get address to use bind() */ #define AI_CANONNAME 0x00000002 /* fill ai_canonname */ #define AI_NUMERICHOST 0x00000004 /* prevent name resolution */ +#define AI_NUMERICSERV 0x00000008 /* prevent service name resolution */ /* valid flags for addrinfo */ #ifndef __HAIKU__ -#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST) +#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV) #endif #define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */ diff --git a/ext/socket/getaddrinfo.c b/ext/socket/getaddrinfo.c index de16b9fb12..ef01a607be 100644 --- a/ext/socket/getaddrinfo.c +++ b/ext/socket/getaddrinfo.c @@ -375,6 +375,8 @@ getaddrinfo(const char *hostname, const char *servname, const struct addrinfo *h pai->ai_protocol = IPPROTO_UDP; } port = htons((unsigned short)atoi(servname)); + } else if (pai->ai_flags & AI_NUMERICSERV) { + ERR(EAI_NONAME); } else { struct servent *sp; const char *proto; |