diff options
| author | Renato Westphal <renato@opensourcerouting.org> | 2018-10-19 15:53:55 -0300 |
|---|---|---|
| committer | Renato Westphal <renato@opensourcerouting.org> | 2018-10-20 12:39:05 -0300 |
| commit | fbcdff8229519bce83f34ea327f6000d21c24d61 (patch) | |
| tree | 478fe47a3ec9715fd9579f07c119c28906ae8670 /bgpd/bgp_lcommunity.c | |
| parent | 2ba315c80192db294786d244d7a31a7f680f0fc4 (diff) | |
bgpd: handle NULL pointers in lcommunity_cmp()
Like community_cmp() and ecommunity_cmp(), the lcommunity_cmp() function
also needs to handle NULL pointers for correct operation.
Without this fix, bgpd can crash when entering the following commands:
vtysh -c "configure terminal" -c "ip large-community-list standard WORD deny"
vtysh -c "configure terminal" -c "no ip large-community-list expanded WORD"
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'bgpd/bgp_lcommunity.c')
| -rw-r--r-- | bgpd/bgp_lcommunity.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/bgpd/bgp_lcommunity.c b/bgpd/bgp_lcommunity.c index 3e160bc56e..2106b9d521 100644 --- a/bgpd/bgp_lcommunity.c +++ b/bgpd/bgp_lcommunity.c @@ -318,6 +318,12 @@ int lcommunity_cmp(const void *arg1, const void *arg2) const struct lcommunity *lcom1 = arg1; const struct lcommunity *lcom2 = arg2; + if (lcom1 == NULL && lcom2 == NULL) + return 1; + + if (lcom1 == NULL || lcom2 == NULL) + return 0; + return (lcom1->size == lcom2->size && memcmp(lcom1->val, lcom2->val, lcom_length(lcom1)) == 0); } |
