summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDonatas Abraitis <donatas.abraitis@gmail.com>2020-03-06 14:29:11 +0100
committerGitHub <noreply@github.com>2020-03-06 14:29:11 +0100
commit9c37fcdddaee63dbd71d8dac1d5a54add74e2665 (patch)
tree181003f904bd6723582bf9f8e945d358e3f18c86
parentMerge pull request #5916 from mjstapp/fix_gmtime (diff)
parentbgpd: properly initialize SRv6 attributes (diff)
downloadfrr-9c37fcdddaee63dbd71d8dac1d5a54add74e2665.tar.xz
frr-9c37fcdddaee63dbd71d8dac1d5a54add74e2665.zip
Merge pull request #5920 from qlyoung/fix-srv6-repeated-attr-memleak
Fix srv6 repeated attr memleak + uninitialized refcnt
-rw-r--r--bgpd/bgp_attr.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c
index f00bb2b3c..33466957b 100644
--- a/bgpd/bgp_attr.c
+++ b/bgpd/bgp_attr.c
@@ -2506,9 +2506,14 @@ static bgp_attr_parse_ret_t bgp_attr_psid_sub(uint8_t type, uint16_t length,
}
/* Configure from Info */
- attr->srv6_vpn = XMALLOC(MTYPE_BGP_SRV6_VPN,
+ if (attr->srv6_vpn) {
+ flog_err(EC_BGP_ATTRIBUTE_REPEATED,
+ "Prefix SID SRv6 VPN field repeated");
+ return bgp_attr_malformed(
+ args, BGP_NOTIFY_UPDATE_MAL_ATTR, args->total);
+ }
+ attr->srv6_vpn = XCALLOC(MTYPE_BGP_SRV6_VPN,
sizeof(struct bgp_attr_srv6_vpn));
- attr->srv6_vpn->refcnt = 0;
attr->srv6_vpn->sid_flags = sid_flags;
sid_copy(&attr->srv6_vpn->sid, &ipv6_sid);
}
@@ -2543,7 +2548,13 @@ static bgp_attr_parse_ret_t bgp_attr_psid_sub(uint8_t type, uint16_t length,
}
/* Configure from Info */
- attr->srv6_l3vpn = XMALLOC(MTYPE_BGP_SRV6_L3VPN,
+ if (attr->srv6_l3vpn) {
+ flog_err(EC_BGP_ATTRIBUTE_REPEATED,
+ "Prefix SID SRv6 L3VPN field repeated");
+ return bgp_attr_malformed(
+ args, BGP_NOTIFY_UPDATE_MAL_ATTR, args->total);
+ }
+ attr->srv6_l3vpn = XCALLOC(MTYPE_BGP_SRV6_L3VPN,
sizeof(struct bgp_attr_srv6_l3vpn));
attr->srv6_l3vpn->sid_flags = sid_flags;
attr->srv6_l3vpn->endpoint_behavior = endpoint_behavior;