diff options
author | Nitin Soni <nsoni@cumulusnetworks.com> | 2019-01-29 15:29:57 +0100 |
---|---|---|
committer | Nitin Soni <nsoni@cumulusnetworks.com> | 2019-01-29 15:29:57 +0100 |
commit | 8ba7105057357c566a0475b32829241cca85d848 (patch) | |
tree | 7e7414b6317fa856bf162c85eec56a4b5698e2b2 /bgpd/bgp_route.c | |
parent | Merge pull request #3686 from qlyoung/fix-termtable-overflow (diff) | |
download | frr-8ba7105057357c566a0475b32829241cca85d848.tar.xz frr-8ba7105057357c566a0475b32829241cca85d848.zip |
bgpd: fix valgrind flagged errors
Executed some evpn related tests with valgrind and saw some errors
related to uninitialized memory and overlapping memcpy. This commit
fixes those.
Ticket: CM-21218
Signed-off-by: Nitin Soni <nsoni@cumulusnetworks.com>
Reviewed-by: CCR-8249
Diffstat (limited to '')
-rw-r--r-- | bgpd/bgp_route.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 07077dfe1..804b035b8 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -3245,9 +3245,11 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id, /* Update MPLS label */ if (has_valid_label) { extra = bgp_path_info_extra_get(pi); - memcpy(&extra->label, label, - num_labels * sizeof(mpls_label_t)); - extra->num_labels = num_labels; + if (extra->label != label) { + memcpy(&extra->label, label, + num_labels * sizeof(mpls_label_t)); + extra->num_labels = num_labels; + } if (!(afi == AFI_L2VPN && safi == SAFI_EVPN)) bgp_set_valid_label(&extra->label[0]); } @@ -3416,8 +3418,10 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id, /* Update MPLS label */ if (has_valid_label) { extra = bgp_path_info_extra_get(new); - memcpy(&extra->label, label, num_labels * sizeof(mpls_label_t)); - extra->num_labels = num_labels; + if (extra->label != label) { + memcpy(&extra->label, label, num_labels * sizeof(mpls_label_t)); + extra->num_labels = num_labels; + } if (!(afi == AFI_L2VPN && safi == SAFI_EVPN)) bgp_set_valid_label(&extra->label[0]); } |