Only guess port separators for domains requiring it
This commit is contained in:
parent
fed91ed241
commit
c45ccdf52f
|
@ -21,7 +21,7 @@ static struct addrinfo * _init_address(char const * name, int domain, int flags)
|
||||||
struct addrinfo * ai = NULL;
|
struct addrinfo * ai = NULL;
|
||||||
char * hostname;
|
char * hostname;
|
||||||
char * servname;
|
char * servname;
|
||||||
char sep = ':';
|
char sep;
|
||||||
char * p;
|
char * p;
|
||||||
char * q;
|
char * q;
|
||||||
long l;
|
long l;
|
||||||
|
@ -38,9 +38,22 @@ static struct addrinfo * _init_address(char const * name, int domain, int flags)
|
||||||
error_set_code(1, "%s", "Empty names are not allowed");
|
error_set_code(1, "%s", "Empty names are not allowed");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/* guess the port separator */
|
/* obtain the port separator */
|
||||||
if((p = strchr(name, ':')) != NULL && strchr(++p, ':') != NULL)
|
switch(domain)
|
||||||
|
{
|
||||||
|
case AF_INET6:
|
||||||
|
case AF_UNSPEC:
|
||||||
|
if((p = strchr(name, ':')) != NULL
|
||||||
|
&& strchr(++p, ':') != NULL)
|
||||||
sep = '.';
|
sep = '.';
|
||||||
|
else
|
||||||
|
sep = ':';
|
||||||
|
break;
|
||||||
|
case AF_INET:
|
||||||
|
default:
|
||||||
|
sep = ':';
|
||||||
|
break;
|
||||||
|
}
|
||||||
/* obtain the name */
|
/* obtain the name */
|
||||||
if((p = strdup(name)) == NULL)
|
if((p = strdup(name)) == NULL)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user