mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-26 05:55:15 +00:00
Fix crash on invalid domain
This commit is contained in:
parent
d504ee6975
commit
49e48d4028
1 changed files with 21 additions and 17 deletions
|
@ -12,23 +12,27 @@
|
||||||
|
|
||||||
|
|
||||||
void domain_resolution(void) {
|
void domain_resolution(void) {
|
||||||
struct in_addr addr;
|
struct in_addr addr;
|
||||||
char *host_name;
|
char *host_name = configJoinIp;
|
||||||
struct hostent *remoteHost;
|
struct hostent *remoteHost;
|
||||||
char* domainname = "";
|
char* domainname = "";
|
||||||
host_name = configJoinIp;
|
host_name = configJoinIp;
|
||||||
if (host_name == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int i = 0;
|
|
||||||
remoteHost = gethostbyname(host_name);
|
|
||||||
i = 0;
|
|
||||||
if (remoteHost->h_addrtype == AF_INET) {
|
|
||||||
|
|
||||||
while (remoteHost->h_addr_list[i] != 0) {
|
if (host_name == NULL) {
|
||||||
addr.s_addr = *(u_long *) remoteHost->h_addr_list[i++];
|
return;
|
||||||
domainname = inet_ntoa(addr);
|
}
|
||||||
snprintf(configJoinIp, MAX_CONFIG_STRING, "%s", domainname);
|
|
||||||
|
int i = 0;
|
||||||
|
remoteHost = gethostbyname(host_name);
|
||||||
|
if (remoteHost == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (remoteHost->h_addrtype == AF_INET) {
|
||||||
|
while (remoteHost->h_addr_list[i] != 0) {
|
||||||
|
addr.s_addr = *(u_long *) remoteHost->h_addr_list[i++];
|
||||||
|
domainname = inet_ntoa(addr);
|
||||||
|
snprintf(configJoinIp, MAX_CONFIG_STRING, "%s", domainname);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue