diff options
| author | Donald Sharp <donaldsharp72@gmail.com> | 2023-08-24 07:43:59 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-24 07:43:59 -0400 |
| commit | 673a11a54fc6948641fe56e41720d0f900c9353c (patch) | |
| tree | 70938b9dff96450c6dbaba3f2756968d8e6508b9 /bgpd/bgp_attr.c | |
| parent | 7090bf430792a67caafdea98d866d2028567d034 (diff) | |
| parent | f96201e104892e18493f24cf67bb713678e8237b (diff) | |
Merge pull request #14232 from opensourcerouting/fix/aigp_validation_bytes
bgpd: Make sure we have enough data to read two bytes when validating AIGP
Diffstat (limited to 'bgpd/bgp_attr.c')
| -rw-r--r-- | bgpd/bgp_attr.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index 45536d2c5c..dcf0f4d47c 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -502,6 +502,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", @@ -510,7 +511,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; |
