diff options
author | 2021-01-05 10:00:28 +0000 | |
---|---|---|
committer | 2021-01-05 10:00:28 +0000 | |
commit | 4886db4cd42464fe42d9a9d09fa1e4280f35f90c (patch) | |
tree | 18fb7011641c21b96839ec6d89c8eec269ffb6ff | |
parent | Add AID_VPN_IPv[46] support to addr2sa. It only converts the address part (diff) | |
download | wireguard-openbsd-4886db4cd42464fe42d9a9d09fa1e4280f35f90c.tar.xz wireguard-openbsd-4886db4cd42464fe42d9a9d09fa1e4280f35f90c.zip |
Revert part of the last addr2sa change. When addr is NULL or AID_UNSPEC
addr2sa needs to return NULL. Without this connection establishment fails
because bind is called with a bad sockaddr.
-rw-r--r-- | usr.sbin/bgpd/util.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.sbin/bgpd/util.c b/usr.sbin/bgpd/util.c index 867538ee167..3ec68293ce9 100644 --- a/usr.sbin/bgpd/util.c +++ b/usr.sbin/bgpd/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.57 2021/01/05 08:18:52 claudio Exp $ */ +/* $OpenBSD: util.c,v 1.58 2021/01/05 10:00:28 claudio Exp $ */ /* * Copyright (c) 2006 Claudio Jeker <claudio@openbsd.org> @@ -841,10 +841,10 @@ addr2sa(const struct bgpd_addr *addr, u_int16_t port, socklen_t *len) struct sockaddr_in *sa_in = (struct sockaddr_in *)&ss; struct sockaddr_in6 *sa_in6 = (struct sockaddr_in6 *)&ss; - bzero(&ss, sizeof(ss)); - if (addr == NULL) - return ((struct sockaddr *)&ss); + if (addr == NULL || addr->aid == AID_UNSPEC) + return (NULL); + bzero(&ss, sizeof(ss)); switch (addr->aid) { case AID_INET: sa_in->sin_family = AF_INET; |