Skip to content

Commit

Permalink
wireguard: Fix use after free
Browse files Browse the repository at this point in the history
Use freeaddrinfo after rp has been used. rp points to an element in
results.

(cherry picked from commit 4b8b2e3)
  • Loading branch information
igaw authored and LaakkonenJussi committed Jul 10, 2024
1 parent 8b6b44e commit d37d965
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions connman/vpn/plugins/wireguard.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,14 @@ static int parse_endpoint(const char *host, const char *port, wg_peer *peer)

close(sk);
}
freeaddrinfo(result);

if (!rp)
if (!rp) {
freeaddrinfo(result);
return -EINVAL;
}

memcpy(&peer->endpoint.addr, rp->ai_addr, rp->ai_addrlen);
freeaddrinfo(result);

return 0;
}
Expand Down

0 comments on commit d37d965

Please sign in to comment.