diff options
author | Matthieu Herrb <matthieu.herrb@laas.fr> | 2009-01-30 22:48:17 +0100 |
---|---|---|
committer | Matthieu Herrb <matthieu.herrb@laas.fr> | 2009-01-30 22:49:28 +0100 |
commit | 332bd687a265642d17109eafb2d183887a53d739 (patch) | |
tree | db2c754a14f0b05c8cbfee6136d462324f480a35 | |
parent | a4f47b755ae85bf3e35a3376fcf44ace67c38767 (diff) |
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.
-rw-r--r-- | access.c | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -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 } |