summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2003-12-30 21:05:10 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2003-12-30 21:05:10 +0000
commit7b295cb0d879219e40dd66e41ee6f82290cc44bd (patch)
tree26673d55aaafc91ffefdbf8524a6c76866ed1a63
parent503a8c85bf9b1b8f59ca6cf77745900bead089c9 (diff)
small logic error in session_open/_keepalive/_notification (yes, the same in
all three) after buf_open failure. as this does not happen normally (except for in out of memory cases) it wasn't noticed.
-rw-r--r--usr.sbin/bgpd/session.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c
index c979b76bcc9..7b49c972403 100644
--- a/usr.sbin/bgpd/session.c
+++ b/usr.sbin/bgpd/session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: session.c,v 1.51 2003/12/30 19:54:23 henning Exp $ */
+/* $OpenBSD: session.c,v 1.52 2003/12/30 21:05:09 henning Exp $ */
/*
* Copyright (c) 2003 Henning Brauer <henning@openbsd.org>
@@ -789,8 +789,10 @@ session_open(struct peer *peer)
msg.bgpid = conf->bgpid; /* is already in network byte order */
msg.optparamlen = 0;
- if ((buf = buf_open(len)) == NULL)
+ if ((buf = buf_open(len)) == NULL) {
bgp_fsm(peer, EVNT_CON_FATAL);
+ return;
+ }
errs += buf_add(buf, &msg.header.marker, sizeof(msg.header.marker));
errs += buf_add(buf, &msg.header.len, sizeof(msg.header.len));
errs += buf_add(buf, &msg.header.type, sizeof(msg.header.type));
@@ -829,8 +831,10 @@ session_keepalive(struct peer *peer)
msg.len = htons(len);
msg.type = KEEPALIVE;
- if ((buf = buf_open(len)) == NULL)
+ if ((buf = buf_open(len)) == NULL) {
bgp_fsm(peer, EVNT_CON_FATAL);
+ return;
+ }
errs += buf_add(buf, &msg.marker, sizeof(msg.marker));
errs += buf_add(buf, &msg.len, sizeof(msg.len));
errs += buf_add(buf, &msg.type, sizeof(msg.type));
@@ -848,6 +852,7 @@ session_keepalive(struct peer *peer)
log_peer_err(peer, "Write error");
buf_free(buf);
bgp_fsm(peer, EVNT_CON_FATAL);
+ return;
}
start_timer_keepalive(peer);
@@ -874,8 +879,10 @@ session_notification(struct peer *peer, u_int8_t errcode, u_int8_t subcode,
msg.len = htons(len);
msg.type = NOTIFICATION;
- if ((buf = buf_open(len)) == NULL)
+ if ((buf = buf_open(len)) == NULL) {
bgp_fsm(peer, EVNT_CON_FATAL);
+ return;
+ }
errs += buf_add(buf, &msg.marker, sizeof(msg.marker));
errs += buf_add(buf, &msg.len, sizeof(msg.len));
errs += buf_add(buf, &msg.type, sizeof(msg.type));