Skip to content

Commit

Permalink
Merge pull request #14268 from FRRouting/mergify/bp/stable/8.5/pr-14232
Browse files Browse the repository at this point in the history
bgpd: Make sure we have enough data to read two bytes when validating AIGP (backport #14232)
  • Loading branch information
donaldsharp authored Aug 24, 2023
2 parents 9993bc1 + 460ee93 commit 5349f4c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions bgpd/bgp_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ static bool bgp_attr_aigp_valid(uint8_t *pnt, int length)
uint8_t *data = pnt;
uint8_t tlv_type;
uint16_t tlv_length;
uint8_t *end = data + length;

if (length < 3) {
zlog_err("Bad AIGP attribute length (MUST be minimum 3): %u",
Expand All @@ -521,7 +522,13 @@ static bool bgp_attr_aigp_valid(uint8_t *pnt, int length)
}

while (length) {
size_t data_len = end - data;

tlv_type = *data;

if (data_len - 1 < 2)
return false;

ptr_get_be16(data + 1, &tlv_length);
(void)data;

Expand Down

0 comments on commit 5349f4c

Please sign in to comment.