summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2021-05-03 13:18:07 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2021-05-03 13:18:07 +0000
commit518982d622d2994873279f54c7c550d3b51030b1 (patch)
tree4cb3770babb3be4d64cb51240b36e0b06ddb24a5 /usr.sbin
parent3dc8917973f7ba9df13b32afccfa6db858a7d004 (diff)
Like in the session engine do not inline the addr2sa call into connect and
bind. The len argument is modified by addr2sa but is also used as argument in the call and it is undefined if the value of len in connect is set to the value "returned" by addr2sa(). Should fix connect issues seen on Linux system. OK denis@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bgpd/bgpd.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/usr.sbin/bgpd/bgpd.c b/usr.sbin/bgpd/bgpd.c
index e6bf4c88d49..72233aa88f4 100644
--- a/usr.sbin/bgpd/bgpd.c
+++ b/usr.sbin/bgpd/bgpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgpd.c,v 1.234 2021/02/16 08:29:16 claudio Exp $ */
+/* $OpenBSD: bgpd.c,v 1.235 2021/05/03 13:18:06 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -1261,6 +1261,7 @@ imsg_send_sockets(struct imsgbuf *se, struct imsgbuf *rde, struct imsgbuf *roa)
void
bgpd_rtr_connect(struct rtr_config *r)
{
+ struct sockaddr *sa;
socklen_t len;
int fd;
@@ -1270,8 +1271,8 @@ bgpd_rtr_connect(struct rtr_config *r)
log_warn("rtr %s", r->descr);
return;
}
- if (r->local_addr.aid != AID_UNSPEC) {
- if (bind(fd, addr2sa(&r->local_addr, 0, &len), len) == -1) {
+ if ((sa = addr2sa(&r->local_addr, 0, &len)) != NULL) {
+ if (bind(fd, sa, len) == -1) {
log_warn("rtr %s: bind to %s", r->descr,
log_addr(&r->local_addr));
close(fd);
@@ -1279,8 +1280,8 @@ bgpd_rtr_connect(struct rtr_config *r)
}
}
- if (connect(fd, addr2sa(&r->remote_addr, r->remote_port, &len), len) ==
- -1) {
+ sa = addr2sa(&r->remote_addr, r->remote_port, &len);
+ if (connect(fd, sa, len) == -1) {
log_warn("rtr %s: connect to %s:%u", r->descr,
log_addr(&r->remote_addr), r->remote_port);
close(fd);