summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2024-06-28 10:34:49 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2024-07-12 09:27:27 +1000
commitf274c3f0ba6b100ac8717cce79dd8043094eba68 (patch)
treeb1acd1cf86a093496fb3d6de5c39d1eb67f31450
parentb1a7317da58136686983c1a50e7f7d3a731dde02 (diff)
Replace inet_addr()/inet_aton() with a call to inet_pton()HEADmaster
We unconditionally require inet_pton() for our IPv6 check so let's use the same call for the IPv4 check too. This removes the need for inet_aton() which is labelled as deprecated because it doesn't support IPv6. Part-of: <https://gitlab.freedesktop.org/xorg/app/xhost/-/merge_requests/8>
-rw-r--r--configure.ac3
-rw-r--r--xhost.c7
2 files changed, 1 insertions, 9 deletions
diff --git a/configure.ac b/configure.ac
index 60a74c2..802eccb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -42,9 +42,6 @@ case $host_os in
;;
esac
-# Checks for library functions.
-AC_CHECK_FUNCS([inet_aton])
-
# Internationalization & localization support
AC_SEARCH_LIBS([gettext], [intl], [USE_GETTEXT="yes"], [USE_GETTEXT="no"])
AC_MSG_CHECKING([where to install localized messages])
diff --git a/xhost.c b/xhost.c
index 22304bd..26ba179 100644
--- a/xhost.c
+++ b/xhost.c
@@ -544,12 +544,7 @@ change_host(Display *dpy, char *name, Bool add)
* First see if inet_aton/inet_addr can grok the name; if so, then use it.
*/
if (((family == FamilyWild) || (family == FamilyInternet)) &&
-#ifdef HAVE_INET_ATON
- (inet_aton (name, &addr) != 0)
-#else
- ((addr.s_addr = inet_addr(name)) != -1)
-#endif
- ) {
+ (inet_pton (AF_INET, name, &addr) == 1)) {
ha.family = FamilyInternet;
ha.length = sizeof(addr.s_addr);
ha.address = (char *) &addr.s_addr;