diff options
Diffstat (limited to 'main')
| -rw-r--r-- | main/network.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/main/network.c b/main/network.c index 6072e76e72..702509a9d9 100644 --- a/main/network.c +++ b/main/network.c @@ -24,6 +24,7 @@ #include "php.h" #include <stddef.h> +#include <errno.h> @@ -105,6 +106,10 @@ const struct in6_addr in6addr_any = {0}; /* IN6ADDR_ANY_INIT; */ # define PHP_TIMEOUT_ERROR_VALUE ETIMEDOUT #endif +#ifndef MAXHOSTNAMELEN +#define MAXHOSTNAMELEN 255 +#endif + #if HAVE_GETADDRINFO #ifdef HAVE_GAI_STRERROR # define PHP_GAI_STRERROR(x) (gai_strerror(x)) @@ -246,7 +251,12 @@ PHPAPI int php_network_getaddresses(const char *host, int socktype, struct socka #else if (!inet_aton(host, &in)) { /* XXX NOT THREAD SAFE (is safe under win32) */ - host_info = gethostbyname(host); + if(strlen(host) > MAXHOSTNAMELEN) { + host_info = NULL; + errno = E2BIG; + } else { + host_info = gethostbyname(host); + } if (host_info == NULL) { if (error_string) { spprintf(error_string, 0, "php_network_getaddresses: gethostbyname failed. errno=%d", errno); |
