Skip to content

Commit

Permalink
bgpd: Make sure hdr length is at a minimum of what is expected
Browse files Browse the repository at this point in the history
Ensure that if the capability length specified is enough data.

Signed-off-by: Donald Sharp <[email protected]>
  • Loading branch information
donaldsharp committed Jul 22, 2022
1 parent 49efc80 commit ff6db10
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions bgpd/bgp_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -2620,6 +2620,14 @@ static int bgp_capability_msg_parse(struct peer *peer, uint8_t *pnt,
"%s CAPABILITY has action: %d, code: %u, length %u",
peer->host, action, hdr->code, hdr->length);

if (hdr->length < sizeof(struct capability_mp_data)) {
zlog_info(
"%pBP Capability structure is not properly filled out, expected at least %zu bytes but header length specified is %d",
peer, sizeof(struct capability_mp_data),
hdr->length);
return BGP_Stop;
}

/* Capability length check. */
if ((pnt + hdr->length + 3) > end) {
zlog_info("%s Capability length error", peer->host);
Expand Down

0 comments on commit ff6db10

Please sign in to comment.