diff options
Diffstat (limited to 'Modules/getaddrinfo.c')
-rw-r--r-- | Modules/getaddrinfo.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Modules/getaddrinfo.c b/Modules/getaddrinfo.c index 0b4620e..f1c28d7 100644 --- a/Modules/getaddrinfo.c +++ b/Modules/getaddrinfo.c @@ -342,7 +342,11 @@ getaddrinfo(const char*hostname, const char*servname, pai->ai_socktype = SOCK_DGRAM; pai->ai_protocol = IPPROTO_UDP; } - port = htons((u_short)atoi(servname)); + long maybe_port = strtol(servname, NULL, 10); + if (maybe_port < 0 || maybe_port > 0xffff) { + ERR(EAI_SERVICE); + } + port = htons((u_short)maybe_port); } else { struct servent *sp; const char *proto; |