Commit 97f7efa9 authored by Nick Mathewson's avatar Nick Mathewson 🦀
Browse files

pf: when extracting an IPv6 address, make sure we got an IPv6 address

Our code assumes that when we're configured to get IPv6 addresses
out of a TRANS_PF transparent proxy connection, we actually will.
But we didn't check that, and so FreeBSD started warning us about a
potential NULL pointer dereference.

Fixes part of bug 31687; bugfix on when this code was
parent 51475aee
o Minor bugfixes (FreeBSD, PF-based proxy, IPv6):
- When extracting an IPv6 address from a PF-based proxy, verify
that we are actually configured to receive an IPv6 address,
and log an internal error if not. Fixes part of bug 31687;
bugfix on
......@@ -2547,8 +2547,11 @@ destination_from_pf(entry_connection_t *conn, socks_request_t *req)
} else if (proxy_sa->sa_family == AF_INET6) {
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)proxy_sa; = AF_INET6;
memcpy(&pnl.saddr.v6, tor_addr_to_in6(&ENTRY_TO_CONN(conn)->addr),
sizeof(struct in6_addr));
const struct in6_addr *dest_in6 =
if (BUG(!dest_in6))
return -1;
memcpy(&pnl.saddr.v6, dest_in6, sizeof(struct in6_addr)); = htons(ENTRY_TO_CONN(conn)->port);
memcpy(&pnl.daddr.v6, &sin6->sin6_addr, sizeof(struct in6_addr));
pnl.dport = sin6->sin6_port;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment