Skip to content

Commit

Permalink
Merge pull request #14267 from FRRouting/mergify/bp/stable/9.0/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 committed Aug 24, 2023
2 parents 2466090 + d8258f9 commit f757594
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions bgpd/bgp_attr.c
Expand Up @@ -492,6 +492,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 @@ -500,7 +501,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 f757594

Please sign in to comment.