From dbc0491f20c34cf3b7ab8fe2a55442ea93007ddd Mon Sep 17 00:00:00 2001 From: corubba Date: Sun, 8 Dec 2024 00:17:05 +0100 Subject: [PATCH] Fix IPv6 in port-share journal getpeername() and getsockname() will truncate the result if it is larger than the passed-in length. Because here always the size of the `sa` IPv4 union member was passed in, all larger (aka IPv6) results were truncated. Instead use the size of the `addr` union, which is the maximum size of all union members. The bug was introduced in 0b6450c9. Trac: #1358 Signed-off-by: corubba Acked-by: Gert Doering Message-Id: <8de5660b-d917-4092-8871-250495d8c7a4@gmx.de> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30035.html Signed-off-by: Gert Doering --- src/openvpn/ps.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/openvpn/ps.c b/src/openvpn/ps.c index 4ca3a129e18..06bf91a86ec 100644 --- a/src/openvpn/ps.c +++ b/src/openvpn/ps.c @@ -344,8 +344,8 @@ journal_add(const char *journal_dir, struct proxy_connection *pc, struct proxy_c char *jfn; int fd; - slen = sizeof(from.addr.sa); - dlen = sizeof(to.addr.sa); + slen = sizeof(from.addr); + dlen = sizeof(to.addr); if (!getpeername(pc->sd, (struct sockaddr *) &from.addr.sa, &slen) && !getsockname(cp->sd, (struct sockaddr *) &to.addr.sa, &dlen)) {