Merge branch 'rs/daemon-fixes'
"git daemon" (with NO_IPV6 build configuration) used to incorrectly use the hostname even when gethostbyname() reported that the given hostname is not found. * rs/daemon-fixes: daemon: remove write-only variable maxfd daemon: fix error message after bind() daemon: handle gethostbyname() error
This commit is contained in:
commit
dc11fc2de8
9
daemon.c
9
daemon.c
@ -553,7 +553,7 @@ static void parse_host_arg(char *extra_args, int buflen)
|
||||
static char addrbuf[HOST_NAME_MAX + 1];
|
||||
|
||||
hent = gethostbyname(hostname);
|
||||
|
||||
if (hent) {
|
||||
ap = hent->h_addr_list;
|
||||
memset(&sa, 0, sizeof sa);
|
||||
sa.sin_family = hent->h_addrtype;
|
||||
@ -567,6 +567,7 @@ static void parse_host_arg(char *extra_args, int buflen)
|
||||
canon_hostname = xstrdup(hent->h_name);
|
||||
free(ip_address);
|
||||
ip_address = xstrdup(addrbuf);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -814,7 +815,6 @@ static const char *ip2str(int family, struct sockaddr *sin, socklen_t len)
|
||||
static int setup_named_sock(char *listen_addr, int listen_port, struct socketlist *socklist)
|
||||
{
|
||||
int socknum = 0;
|
||||
int maxfd = -1;
|
||||
char pbuf[NI_MAXSERV];
|
||||
struct addrinfo hints, *ai0, *ai;
|
||||
int gai;
|
||||
@ -882,9 +882,6 @@ static int setup_named_sock(char *listen_addr, int listen_port, struct socketlis
|
||||
ALLOC_GROW(socklist->list, socklist->nr + 1, socklist->alloc);
|
||||
socklist->list[socklist->nr++] = sockfd;
|
||||
socknum++;
|
||||
|
||||
if (maxfd < sockfd)
|
||||
maxfd = sockfd;
|
||||
}
|
||||
|
||||
freeaddrinfo(ai0);
|
||||
@ -923,7 +920,7 @@ static int setup_named_sock(char *listen_addr, int listen_port, struct socketlis
|
||||
}
|
||||
|
||||
if ( bind(sockfd, (struct sockaddr *)&sin, sizeof sin) < 0 ) {
|
||||
logerror("Could not listen to %s: %s",
|
||||
logerror("Could not bind to %s: %s",
|
||||
ip2str(AF_INET, (struct sockaddr *)&sin, sizeof(sin)),
|
||||
strerror(errno));
|
||||
close(sockfd);
|
||||
|
Loading…
Reference in New Issue
Block a user