Skip to content

Commit

Permalink
bgpd: Set the software version capability received flag only after a …
Browse files Browse the repository at this point in the history
…validation

We shouldn't set it blindly once the packet is received, but first we have to
do some sanity checks.

Signed-off-by: Donatas Abraitis <[email protected]>
(cherry picked from commit 6af6830)
  • Loading branch information
ton31337 authored and mergify[bot] committed Nov 9, 2023
1 parent bfc2a20 commit 591908a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bgpd/bgp_open.c
Original file line number Diff line number Diff line change
Expand Up @@ -889,8 +889,6 @@ static int bgp_capability_software_version(struct peer *peer,
size_t end = stream_get_getp(s) + hdr->length;
uint8_t len;

SET_FLAG(peer->cap, PEER_CAP_SOFT_VERSION_RCV);

len = stream_getc(s);
if (stream_get_getp(s) + len > end) {
flog_warn(
Expand All @@ -900,6 +898,8 @@ static int bgp_capability_software_version(struct peer *peer,
return -1;
}

SET_FLAG(peer->cap, PEER_CAP_SOFT_VERSION_RCV);

if (len > BGP_MAX_SOFT_VERSION) {
flog_warn(EC_BGP_CAPABILITY_INVALID_LENGTH,
"%s: Received Software Version, but the length is too big, truncating, from peer %s",
Expand Down

0 comments on commit 591908a

Please sign in to comment.