getLocalAddress(): return 127.0.0.1 if the hostname doesn't resolve.
This code already does this if IPv6 support is compiled in. It was dereferencing a NULL pointer in the IPv4 only case.
This commit is contained in:
parent
fef4aae88f
commit
8fd38b9171
@ -139,8 +139,17 @@ getLocalAddress (void)
|
||||
struct hostent *hostent;
|
||||
|
||||
hostent = gethostbyname (localHostname());
|
||||
XdmcpAllocARRAY8 (&localAddress, hostent->h_length);
|
||||
memmove( localAddress.data, hostent->h_addr, hostent->h_length);
|
||||
if (hostent != NULL) {
|
||||
XdmcpAllocARRAY8 (&localAddress, hostent->h_length);
|
||||
memmove(localAddress.data, hostent->h_addr, hostent->h_length);
|
||||
} else {
|
||||
/* Assume 127.0.0.1 */
|
||||
XdmcpAllocARRAY8 (&localAddress, 4);
|
||||
localAddress.data[0] = 127;
|
||||
localAddress.data[1] = 0;
|
||||
localAddress.data[2] = 0;
|
||||
localAddress.data[3] = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user