Fix IPv6 in port-share journal
PATCH 1/2 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.
Fixes https://community.openvpn.net/openvpn/ticket/1358
--- src/openvpn/ps.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
src/openvpn/ps.c +2 -2
@@ -344,8 +344,8 @@ journal_add(const char *journal_dir, struct proxy_connection *pc, struct proxy_cchar *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)) {
--
2.47.1
PATCH 2/2 Fix port-share journal doc
Filename and content descriptions were switched.
--- doc/man-sections/server-options.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
doc/man-sections/server-options.rst +1 -1
@@ -429,7 +429,7 @@ fast hardware. SSL/TLS authentication must be used in this mode. ``dir`` specifies an optional directory where a temporary file with name N containing content C will be dynamically generated for each proxy - connection, where N is the source IP:port of the client connection and C + connection, where C is the source IP:port of the client connection and N is the source IP:port of the connection to the proxy receiver. This directory can be used as a dictionary by the proxy receiver to determine the origin of the connection. Each generated file will be automatically
--
2.47.1
Hi,
Quoted 5 lines · corubba via Openvpn-devel
getpeername()andgetsockname()will truncate the result if it is larger than the passed-in length. Because here always the size of thesaIPv4 union member was passed in, all larger (aka IPv6) results were truncated. Instead use the size of theaddrunion, which is the maximum size of all union members.
Thanks for digging into this. The fix looks correct according to structure definitions, "man getpeername()" etc. - and now matches other parts of the code, like socket.c / socket_do_accept()
...
socklen_t remote_len = sizeof(act->dest.addr);
...
new_sd = getpeername(sd, &act->dest.addr.sa, &remote_len);The commit ID you found introduces IPv6 transport support :-) - so before that, there was no ambiguity here.
So
will proceed to merge ASAP. (I'll change the Trac reference to be just "Trac: #1358" as this is our standard format).
gert
Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you
feed honest figures into a computer, honest figures come out. Never doubted
it myself till I met a computer with a sense of humor."
Robert A. Heinlein, The Moon is a Harsh Mistress
Gert Doering - Munich, Germany [email protected]...I have not actually tested this (beyond "GHA run" passed) because I have no current test setup for incoming port share with journal files - but the code change is "obviously correct" and our picky compilers do not object either.
Your patch has been applied to the master and release/2.6 branch (bugfix).
commit dbc0491f20c34cf3b7ab8fe2a55442ea93007ddd (master) commit f966e67c24af681cdd8c3905f4da07e616a123c5 (release/2.6)
Author: corubba Date: Sun Dec 8 00:17:05 2024 +0100
Fix IPv6 in port-share journal
Signed-off-by: corubba <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg30035.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
[Openvpn-devel] [PATCH applied] Re: Fix port-share journal doc
In reply to corubbaNeither the code nor the manpage are particularily easy to digest, but after staring at the code for quite a bit I have to agree with your manpage fix. The "to" bit goes into the filename...
&& !getsockname(cp->sd, (struct sockaddr *) &to.addr.sa, &dlen))
..
const char *t = print_openvpn_sockaddr(&to, &gc);
fnlen = strlen(journal_dir) + strlen(t) + 2;
snprintf(jfn, fnlen, "%s/%s", journal_dir, t);.. and the "from" bit into the file content.
if (!getpeername(pc->sd, (struct sockaddr *) &from.addr.sa, &slen)
..
const char *f = print_openvpn_sockaddr(&from, &gc);
if (write(fd, f, strlen(f)) != strlen(f))Your patch has been applied to the master and release/2.6 branch (bugfix).
commit 9343cd101d74377305b96cd501b8659f64c70e46 (master) commit 6d64fa4bfff935eb82f9786f709126ab02f0d8b3 (release/2.6)
Author: corubba Date: Sun Dec 8 00:19:35 2024 +0100
Fix port-share journal doc
Signed-off-by: corubba <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg30036.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering