Replace inet_aton() with inet_pton() to silence rpminspect

Resolves: RHEL-45375
This commit is contained in:
Peter Hutterer 2024-06-28 12:35:59 +10:00
parent 4aebec5e2d
commit 1d8c3297cb
2 changed files with 56 additions and 1 deletions

View File

@ -0,0 +1,50 @@
From 26aaeb86431dc81234a46e63386a9a0b5c1f2af8 Mon Sep 17 00:00:00 2001
From: Peter Hutterer <peter.hutterer@who-t.net>
Date: Fri, 28 Jun 2024 10:34:49 +1000
Subject: [PATCH app/xhost] Replace inet_addr()/inet_aton() with a call to
inet_pton()
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
IPv4.
---
configure.ac | 3 ---
xhost.c | 7 +------
2 files changed, 1 insertion(+), 9 deletions(-)
diff --git a/configure.ac b/configure.ac
index 60a74c21e580..802eccb959ad 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 22304bd814b4..26ba179272bb 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;
--
2.45.2

View File

@ -1,12 +1,14 @@
Name: xhost
Version: 1.0.9
Release: 7%{?dist}
Release: 8%{?dist}
Summary: Manage hosts or users allowed to connect to the X server
License: MIT AND ICU
URL: https://www.x.org
Source0: https://www.x.org/pub/individual/app/%{name}-%{version}.tar.xz
Patch01: 0001-Replace-inet_addr-inet_aton-with-a-call-to-inet_pton.patch
BuildRequires: automake libtool
BuildRequires: gcc make gettext
BuildRequires: pkgconfig(x11)
@ -38,6 +40,9 @@ autoreconf -v --install
%{_mandir}/man1/%{name}.1*
%changelog
* Fri Jun 28 2024 Peter Hutterer <peter.hutterer@redhat.com> - 1.0.9-8
- Replace inet_aton() with inet_pton() to silence rpminspect
* Mon Jun 24 2024 Troy Dawson <tdawson@redhat.com> - 1.0.9-7
- Bump release for June 2024 mass rebuild