From 62bfa9d421138ec538682eb0323fa9f438d6b2c7 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Mon, 12 Nov 2018 13:27:55 -0800 Subject: Prefer inet_aton, if available, over inet_addr Signed-off-by: Alan Coopersmith --- configure.ac | 3 +++ xhost.c | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 47147df..d174e42 100644 --- a/configure.ac +++ b/configure.ac @@ -42,6 +42,9 @@ case $host_os in ;; esac +# Checks for library functions. +AC_CHECK_FUNCS([inet_aton]) + AC_CONFIG_FILES([ Makefile man/Makefile]) 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 */ -- cgit v1.2.3