Skip to content

Commit

Permalink
Fix IPv6 in port-share journal
Browse files Browse the repository at this point in the history
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 0b6450c.

Trac: #1358

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]>
(cherry picked from commit dbc0491)
  • Loading branch information
corubba authored and cron2 committed Dec 8, 2024
1 parent 2776810 commit f966e67
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/openvpn/ps.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down

0 comments on commit f966e67

Please sign in to comment.