]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Fix IPv6 in port-share journal
authorcorubba <corubba@gmx.de>
Sat, 7 Dec 2024 23:17:05 +0000 (00:17 +0100)
committerGert Doering <gert@greenie.muc.de>
Sun, 8 Dec 2024 13:56:19 +0000 (14:56 +0100)
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 <corubba@gmx.de>
Acked-by: Gert Doering <gert@greenie.muc.de>
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 <gert@greenie.muc.de>
src/openvpn/ps.c

index 4ca3a129e183a8e047c84b2186ab9fa8c9664dcf..06bf91a86ece5159b45ada38424ec3ca14f5afae 100644 (file)
@@ -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))
     {