X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/9f802c7294e11562afd0edb75b80f7a49a9fb43d..0cdb547f5c79506686a67da65edd3ae0b3c581c1:/lib/getaddrinfo.c diff --git a/lib/getaddrinfo.c b/lib/getaddrinfo.c index 3e815577..b7432870 100644 --- a/lib/getaddrinfo.c +++ b/lib/getaddrinfo.c @@ -53,8 +53,15 @@ TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. #define SMB_STRDUP(s) strdup(s) #endif +#ifndef HOST_NAME_MAX +#define HOST_NAME_MAX 255 +#endif + static int check_hostent_err(struct hostent *hp) { +#ifndef INET6 + extern int h_errno; +#endif if (!hp) { switch (h_errno) { case HOST_NOT_FOUND: @@ -106,7 +113,7 @@ static char *get_canon_name_from_addr(struct in_addr ip, int *perr) { return canon_name_from_hostent( - gethostbyaddr(&ip, sizeof(ip), AF_INET), + gethostbyaddr((void *)&ip, sizeof ip, AF_INET), perr); } @@ -153,7 +160,7 @@ static struct addrinfo *alloc_entry(const struct addrinfo *hints, */ static int getaddr_info_single_addr(const char *service, - uint32_t addr, + uint32 addr, const struct addrinfo *hints, struct addrinfo **res) { @@ -399,8 +406,8 @@ static int gethostnameinfo(const struct sockaddr *sa, if (!(flags & NI_NUMERICHOST)) { struct hostent *hp = gethostbyaddr( - &((struct sockaddr_in *)sa)->sin_addr, - sizeof(struct in_addr), + (void *)&((struct sockaddr_in *)sa)->sin_addr, + sizeof (struct in_addr), sa->sa_family); ret = check_hostent_err(hp); if (ret == 0) { @@ -481,17 +488,14 @@ int getnameinfo(const struct sockaddr *sa, socklen_t salen, return EAI_FAIL; } - if (salen < sizeof(struct sockaddr_in)) { + if (salen < (socklen_t)sizeof (struct sockaddr_in)) { return EAI_FAIL; } - /* We don't support those. */ - if ((node && !(flags & NI_NUMERICHOST)) - || (service && !(flags & NI_NUMERICSERV))) - return EAI_FAIL; - if (node) { - return gethostnameinfo(sa, node, nodelen, flags); + int ret = gethostnameinfo(sa, node, nodelen, flags); + if (ret) + return ret; } if (service) {