@@ -397,6 +397,14 @@ static void make_service_overridable(const char *name, int ena)
397
397
die ("No such service %s" , name );
398
398
}
399
399
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
+
400
408
/*
401
409
* Separate the "extra args" information as supplied by the client connection.
402
410
*/
@@ -405,7 +413,6 @@ static void parse_extra_args(char *extra_args, int buflen)
405
413
char * val ;
406
414
int vallen ;
407
415
char * end = extra_args + buflen ;
408
- char * hp ;
409
416
410
417
while (extra_args < end && * extra_args ) {
411
418
saw_extended_args = 1 ;
@@ -423,28 +430,19 @@ static void parse_extra_args(char *extra_args, int buflen)
423
430
tcp_port = xstrdup (port );
424
431
}
425
432
free (hostname );
426
- hostname = xstrdup (host );
433
+ hostname = xstrdup_tolower (host );
427
434
}
428
435
429
436
/* On to the next one */
430
437
extra_args = val + vallen ;
431
438
}
432
439
}
433
440
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
-
443
441
/*
444
442
* Locate canonical hostname and its IP address.
445
443
*/
444
+ if (hostname ) {
446
445
#ifndef NO_IPV6
447
- {
448
446
struct addrinfo hints ;
449
447
struct addrinfo * ai , * ai0 ;
450
448
int gai ;
@@ -468,9 +466,7 @@ static void parse_extra_args(char *extra_args, int buflen)
468
466
}
469
467
freeaddrinfo (ai0 );
470
468
}
471
- }
472
469
#else
473
- {
474
470
struct hostent * hent ;
475
471
struct sockaddr_in sa ;
476
472
char * * ap ;
@@ -491,8 +487,8 @@ static void parse_extra_args(char *extra_args, int buflen)
491
487
canon_hostname = xstrdup (hent -> h_name );
492
488
free (ip_address );
493
489
ip_address = xstrdup (addrbuf );
494
- }
495
490
#endif
491
+ }
496
492
}
497
493
498
494
@@ -945,12 +941,8 @@ int main(int argc, char **argv)
945
941
char * arg = argv [i ];
946
942
947
943
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 ;
954
946
}
955
947
if (!prefixcmp (arg , "--port=" )) {
956
948
char * end ;
0 commit comments