net-analyzer/hunt: Fix passing of incompatible pointer type

And update EAPI 7 -> 8

Closes: https://bugs.gentoo.org/919471
Signed-off-by: Brahmajit Das <brahmajit.xyz@gmail.com>
Closes: https://github.com/gentoo/gentoo/pull/36526
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
This commit is contained in:
Brahmajit Das
2024-05-03 23:12:12 +05:30
committed by Arthur Zamarin
parent bfb7b16150
commit d11c3c63ed
2 changed files with 103 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
Bug: https://bugs.gentoo.org/919471
From: Brahmajit Das <brahmajit.xyz@gmail.com>
Date: Fri, 3 May 2024 17:26:49 +0530
Subject: [PATCH 1/1] Fix c99 build errors.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
GCC 14 (and above) has enabled some compiler flags by default,
-Wincompatible-pointer-types being one of them. These results in build
time errors such as
tpserv.c:161:32: error: passing argument 2 of connect from incompatible pointer type [-Wincompatible-pointer-types]
161 | if (connect(fd_remote, to_addr, to_addr_len) < 0) {
| ^~~~~~~
| |
| struct sockaddr_in *
In file included from tpserv.c:11:
/usr/include/sys/socket.h:126:52: note: expected const struct sockaddr * but argument is of type struct sockaddr_in *
TODO: Find better ways other than type casting.
Type casting is the only way for now, as chaning the parameter type in
function defenition would require touching many other parts of the code
that I'm unfamiliar with.
First reported on Gentoo Linux with GCC 14, please reffer
https://bugs.gentoo.org/919471 for more details.
Signed-off-by: Brahmajit Das <brahmajit.xyz@gmail.com>
--- a/tpserv/tpserv.c
+++ b/tpserv/tpserv.c
@@ -148,7 +148,8 @@ static void process_request_connect(int fd, int pid, struct sockaddr_in *from_ad
{
char buf[BUFSIZE];
struct sockaddr_in local_addr;
- int to_addr_len, local_addr_len;
+ int to_addr_len;
+ socklen_t local_addr_len;
fd_set rset;
int maxfd, len;
int fd_remote;
@@ -158,7 +159,13 @@ static void process_request_connect(int fd, int pid, struct sockaddr_in *from_ad
exit(1);
}
to_addr_len = sizeof(*to_addr);
- if (connect(fd_remote, to_addr, to_addr_len) < 0) {
+ /*
+ *TODO: Find better ways other than type casting.
+ *Type casting is the only way for now, as chaning the parameter type in
+ *function defenition would require touching many other parts of the code
+ *that I'm unfamiliar with.
+ */
+ if (connect(fd_remote, (const struct sockaddr *)to_addr, to_addr_len) < 0) {
hunt_log(LOG_ERR, pid, "failed to connect to remote addr\n");
exit(1);
}
--
2.45.0.rc1.218.g7b19149425.dirty

View File

@@ -0,0 +1,44 @@
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
inherit flag-o-matic toolchain-funcs
DESCRIPTION="Tool for checking well known weaknesses in the TCP/IP protocol"
HOMEPAGE="http://lin.fsid.cvut.cz/~kra/index.html"
SRC_URI="
mirror://debian/pool/main/${PN:0:1}/${PN}/${PN}_${PV/_p*}.orig.tar.gz
mirror://debian/pool/main/${PN:0:1}/${PN}/${PN}_${PV/_p*}-$(ver_cut 4).$(ver_cut 6).diff.gz"
S="${WORKDIR}/${P/_p*}"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~ppc ~x86"
PATCHES=(
"${WORKDIR}"/${PN}_1.5-6.1.diff
"${FILESDIR}"/${P/_p*}-exit.patch
"${FILESDIR}"/${P/_p*}-gentoo.patch
"${FILESDIR}"/${P/_p*}-log2.patch
"${FILESDIR}"/${P/_p*}-tpserv-log.patch
"${FILESDIR}"/${P/_p*}-c99-build-fix.patch
)
src_configure() {
append-cppflags -DSYNC_FAST
}
src_compile() {
local target
for target in . tpserv; do
emake CC="$(tc-getCC)" LDFLAGS="${CFLAGS} ${LDFLAGS}" -C "${target}"
done
}
src_install() {
dosbin hunt tpserv/tpserv tpsetup/transproxy
doman man/hunt.1
dodoc CHANGES README* TODO tpsetup/transproxy
newdoc debian/changelog debian.changelog
}