@@ -573,20 +573,21 @@ static void parse_host_arg(char *extra_args, int buflen)
573
573
static char addrbuf [HOST_NAME_MAX + 1 ];
574
574
575
575
hent = gethostbyname (hostname );
576
+ if (hent ) {
577
+ ap = hent -> h_addr_list ;
578
+ memset (& sa , 0 , sizeof sa );
579
+ sa .sin_family = hent -> h_addrtype ;
580
+ sa .sin_port = htons (0 );
581
+ memcpy (& sa .sin_addr , * ap , hent -> h_length );
582
+
583
+ inet_ntop (hent -> h_addrtype , & sa .sin_addr ,
584
+ addrbuf , sizeof (addrbuf ));
576
585
577
- ap = hent -> h_addr_list ;
578
- memset (& sa , 0 , sizeof sa );
579
- sa .sin_family = hent -> h_addrtype ;
580
- sa .sin_port = htons (0 );
581
- memcpy (& sa .sin_addr , * ap , hent -> h_length );
582
-
583
- inet_ntop (hent -> h_addrtype , & sa .sin_addr ,
584
- addrbuf , sizeof (addrbuf ));
585
-
586
- free (canon_hostname );
587
- canon_hostname = xstrdup (hent -> h_name );
588
- free (ip_address );
589
- ip_address = xstrdup (addrbuf );
586
+ free (canon_hostname );
587
+ canon_hostname = xstrdup (hent -> h_name );
588
+ free (ip_address );
589
+ ip_address = xstrdup (addrbuf );
590
+ }
590
591
#endif
591
592
}
592
593
}
@@ -834,7 +835,6 @@ static const char *ip2str(int family, struct sockaddr *sin, socklen_t len)
834
835
static int setup_named_sock (char * listen_addr , int listen_port , struct socketlist * socklist )
835
836
{
836
837
int socknum = 0 ;
837
- int maxfd = -1 ;
838
838
char pbuf [NI_MAXSERV ];
839
839
struct addrinfo hints , * ai0 , * ai ;
840
840
int gai ;
@@ -902,9 +902,6 @@ static int setup_named_sock(char *listen_addr, int listen_port, struct socketlis
902
902
ALLOC_GROW (socklist -> list , socklist -> nr + 1 , socklist -> alloc );
903
903
socklist -> list [socklist -> nr ++ ] = sockfd ;
904
904
socknum ++ ;
905
-
906
- if (maxfd < sockfd )
907
- maxfd = sockfd ;
908
905
}
909
906
910
907
freeaddrinfo (ai0 );
@@ -943,7 +940,7 @@ static int setup_named_sock(char *listen_addr, int listen_port, struct socketlis
943
940
}
944
941
945
942
if ( bind (sockfd , (struct sockaddr * )& sin , sizeof sin ) < 0 ) {
946
- logerror ("Could not listen to %s: %s" ,
943
+ logerror ("Could not bind to %s: %s" ,
947
944
ip2str (AF_INET , (struct sockaddr * )& sin , sizeof (sin )),
948
945
strerror (errno ));
949
946
close (sockfd );
0 commit comments