summaryrefslogtreecommitdiff
path: root/xhost.c
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2018-11-12 13:27:55 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2018-11-12 13:31:51 -0800
commit62bfa9d421138ec538682eb0323fa9f438d6b2c7 (patch)
tree52065fad2301d86f9a591dfcd06b2381fff82bcd /xhost.c
parent0c3627bc7dac395c6af8bd1fb747ef3556e95fb4 (diff)
Prefer inet_aton, if available, over inet_addr
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'xhost.c')
-rw-r--r--xhost.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/xhost.c b/xhost.c
index 7bea7bc..389f896 100644
--- a/xhost.c
+++ b/xhost.c
@@ -509,10 +509,15 @@ change_host(Display *dpy, char *name, Bool add)
}
#ifdef NEEDSOCKETS
/*
- * First see if inet_addr() can grok the name; if so, then use it.
+ * First see if inet_aton/inet_addr can grok the name; if so, then use it.
*/
if (((family == FamilyWild) || (family == FamilyInternet)) &&
- ((addr.s_addr = inet_addr(name)) != -1)) {
+#ifdef HAVE_INET_ATON
+ (inet_aton (name, &addr) != 0)
+#else
+ ((addr.s_addr = inet_addr(name)) != -1)
+#endif
+ ) {
ha.family = FamilyInternet;
ha.length = 4; /* but for Cray would be sizeof(addr.s_addr) */
ha.address = (char *)&addr; /* but for Cray would be &addr.s_addr */