Resolves: RHELMISC-6017 Add patch to avoid using deprecated inet_* functions

This commit is contained in:
Mike FABIAN 2024-07-11 11:22:20 +02:00
parent bb00087b6c
commit f63a0eabdf
2 changed files with 45 additions and 1 deletions

View File

@ -0,0 +1,40 @@
diff -Nru foma-b44022c7d9d347dc7392aabbf72c82e558767675.orig/foma/flookup.c foma-b44022c7d9d347dc7392aabbf72c82e558767675/foma/flookup.c
--- foma-b44022c7d9d347dc7392aabbf72c82e558767675.orig/foma/flookup.c 2020-09-28 21:00:09.000000000 +0200
+++ foma-b44022c7d9d347dc7392aabbf72c82e558767675/foma/flookup.c 2021-06-10 13:57:39.337587755 +0200
@@ -355,6 +355,8 @@
void server_init(void) {
unsigned int rcvsize = 262144;
+ int retval;
+ char server_address_string[INET_ADDRSTRLEN];
if ((listen_sd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) {
perror("socket() failed");
@@ -373,7 +375,15 @@
serveraddr.sin_family = AF_INET;
serveraddr.sin_port = htons(port_number);
if (server_address != NULL) {
- serveraddr.sin_addr.s_addr = inet_addr(server_address);
+ retval = inet_pton(AF_INET, server_address, &serveraddr.sin_addr.s_addr);
+ if (retval != 1) {
+ if (retval == 0) {
+ printf("inet_pton() failed: string is not a valid address.\n");
+ exit(1);
+ }
+ perror("inet_pton() failed");
+ exit(1);
+ }
} else {
serveraddr.sin_addr.s_addr = INADDR_ANY;
}
@@ -381,5 +391,9 @@
perror("bind() failed");
exit(1);
}
- printf("Started flookup server on %s port %i\n", inet_ntoa(serveraddr.sin_addr), port_number); fflush(stdout);
+ if (inet_ntop(AF_INET, &serveraddr.sin_addr, server_address_string, INET_ADDRSTRLEN) == NULL) {
+ perror("inet_ntop() failed");
+ exit(1);
+ }
+ printf("Started flookup server on %s port %i\n", server_address_string, port_number); fflush(stdout);
}

View File

@ -9,7 +9,7 @@
Name: foma
Version: 0.10.0
Release: 0.11.%{snapshotdate}git%{shortcommit0}%{?dist}
Release: 0.12.%{snapshotdate}git%{shortcommit0}%{?dist}
Summary: Xerox-compatible finite-state compiler
License: Apache-2.0
@ -27,6 +27,7 @@ Source0: https://github.com/mhulden/%{name}/archive/%{commit0}.tar.gz#/%{
# issue, see https://lists.debian.org/debian-devel/2016/05/msg00302.html
Patch0: foma-harden-build-fedora.patch
Patch1: foma-c99.patch
Patch2: foma-avoid-deprecated-inet-functions.patch
BuildRequires: gcc zlib-devel readline-devel flex bison
BuildRequires: make
@ -105,6 +106,9 @@ find %{buildroot} -name '*.a' -exec rm -f {} ';'
%changelog
* Thu Jul 11 2024 Mike FABIAN <mfabian@redhat.com> - 0.10.0-0.12.20210601gitdfe1ccb
- Resolves: RHELMISC-6017 Add patch to avoid using deprecated inet_* functions.
* Mon Jun 24 2024 Troy Dawson <tdawson@redhat.com> - 0.10.0-0.11.20210601gitdfe1ccb
- Bump release for June 2024 mass rebuild