@@ -397,6 +397,14 @@ static void make_service_overridable(const char *name, int ena)
397397 die ("No such service %s" , name );
398398}
399399
400+ static char * xstrdup_tolower (const char * str )
401+ {
402+ char * p , * dup = xstrdup (str );
403+ for (p = dup ; * p ; p ++ )
404+ * p = tolower (* p );
405+ return dup ;
406+ }
407+
400408/*
401409 * Separate the "extra args" information as supplied by the client connection.
402410 */
@@ -405,7 +413,6 @@ static void parse_extra_args(char *extra_args, int buflen)
405413 char * val ;
406414 int vallen ;
407415 char * end = extra_args + buflen ;
408- char * hp ;
409416
410417 while (extra_args < end && * extra_args ) {
411418 saw_extended_args = 1 ;
@@ -423,28 +430,19 @@ static void parse_extra_args(char *extra_args, int buflen)
423430 tcp_port = xstrdup (port );
424431 }
425432 free (hostname );
426- hostname = xstrdup (host );
433+ hostname = xstrdup_tolower (host );
427434 }
428435
429436 /* On to the next one */
430437 extra_args = val + vallen ;
431438 }
432439 }
433440
434- /*
435- * Replace literal host with lowercase-ized hostname.
436- */
437- hp = hostname ;
438- if (!hp )
439- return ;
440- for ( ; * hp ; hp ++ )
441- * hp = tolower (* hp );
442-
443441 /*
444442 * Locate canonical hostname and its IP address.
445443 */
444+ if (hostname ) {
446445#ifndef NO_IPV6
447- {
448446 struct addrinfo hints ;
449447 struct addrinfo * ai , * ai0 ;
450448 int gai ;
@@ -468,9 +466,7 @@ static void parse_extra_args(char *extra_args, int buflen)
468466 }
469467 freeaddrinfo (ai0 );
470468 }
471- }
472469#else
473- {
474470 struct hostent * hent ;
475471 struct sockaddr_in sa ;
476472 char * * ap ;
@@ -491,8 +487,8 @@ static void parse_extra_args(char *extra_args, int buflen)
491487 canon_hostname = xstrdup (hent -> h_name );
492488 free (ip_address );
493489 ip_address = xstrdup (addrbuf );
494- }
495490#endif
491+ }
496492}
497493
498494
@@ -945,12 +941,8 @@ int main(int argc, char **argv)
945941 char * arg = argv [i ];
946942
947943 if (!prefixcmp (arg , "--listen=" )) {
948- char * p = arg + 9 ;
949- char * ph = listen_addr = xmalloc (strlen (arg + 9 ) + 1 );
950- while (* p )
951- * ph ++ = tolower (* p ++ );
952- * ph = 0 ;
953- continue ;
944+ listen_addr = xstrdup_tolower (arg + 9 );
945+ continue ;
954946 }
955947 if (!prefixcmp (arg , "--port=" )) {
956948 char * end ;
0 commit comments