SCP/SOCKET: Apply default host more reasonably when parsing host:port strings

This commit is contained in:
Mark Pizzolato 2013-11-26 11:07:21 -08:00
parent 55c5d20517
commit beac643acb

View file

@ -604,7 +604,20 @@ if (host) /* host wanted? */
if (strlen(hostp) >= host_len) if (strlen(hostp) >= host_len)
return SCPE_ARG; /* no room */ return SCPE_ARG; /* no room */
else else
if (('\0' != hostp[0]) || (default_host == NULL))
strcpy (host, hostp); strcpy (host, hostp);
else
if (strlen(default_host) >= host_len)
return SCPE_ARG; /* no room */
else
strcpy (host, default_host);
}
else {
if (default_host)
if (strlen(default_host) >= host_len)
return SCPE_ARG; /* no room */
else
strcpy (host, default_host);
} }
if (validate_addr) { if (validate_addr) {
struct addrinfo *ai_host, *ai_validate, *ai; struct addrinfo *ai_host, *ai_validate, *ai;