summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDonatas Abraitis <donatas@opensourcerouting.org>2024-01-16 13:37:16 +0100
committerDonatas Abraitis <donatas@opensourcerouting.org>2024-01-16 13:37:16 +0100
commit0c74220c6e841a3ca0c8534b34a138d5d05a1ebb (patch)
treea95e3b9271cca64aab14b32424a4ea52b6cd10b1
parentbgpd: Set ADD-PATH capability received flag only if parsed correctly (diff)
downloadfrr-0c74220c6e841a3ca0c8534b34a138d5d05a1ebb.tar.xz
frr-0c74220c6e841a3ca0c8534b34a138d5d05a1ebb.zip
bgpd: Set hostname capability received flag only if parsed correctly
If we receive a malformed packet, we might end-up with a bad state. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
-rw-r--r--bgpd/bgp_open.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/bgpd/bgp_open.c b/bgpd/bgp_open.c
index 8b4f97d62..cb1380174 100644
--- a/bgpd/bgp_open.c
+++ b/bgpd/bgp_open.c
@@ -818,8 +818,6 @@ static int bgp_capability_hostname(struct peer *peer,
size_t end = stream_get_getp(s) + hdr->length;
uint8_t len;
- SET_FLAG(peer->cap, PEER_CAP_HOSTNAME_RCV);
-
len = stream_getc(s);
if (stream_get_getp(s) + len > end) {
flog_warn(
@@ -877,6 +875,8 @@ static int bgp_capability_hostname(struct peer *peer,
peer->domainname = XSTRDUP(MTYPE_BGP_PEER_HOST, str);
}
+ SET_FLAG(peer->cap, PEER_CAP_HOSTNAME_RCV);
+
if (bgp_debug_neighbor_events(peer)) {
zlog_debug("%s received hostname %s, domainname %s", peer->host,
peer->hostname, peer->domainname);