summaryrefslogtreecommitdiffstats
path: root/bgpd
diff options
context:
space:
mode:
authorSri Mohana Singamsetty <srimohans@gmail.com>2019-12-03 02:15:35 +0100
committerGitHub <noreply@github.com>2019-12-03 02:15:35 +0100
commit96fda36733c52e9a1708be8c9cbbfa51339499fa (patch)
treec0eaae515877fc719edd4e5d9947a3e8f0a5a75d /bgpd
parentMerge pull request #5444 from opensourcerouting/show-candidate-fix (diff)
parentbgpd: Prevent crash in bgp_table_range_lookup (diff)
downloadfrr-96fda36733c52e9a1708be8c9cbbfa51339499fa.tar.xz
frr-96fda36733c52e9a1708be8c9cbbfa51339499fa.zip
Merge pull request #5450 from donaldsharp/rpki_node_issues
bgpd: Prevent crash in bgp_table_range_lookup
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_table.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/bgpd/bgp_table.c b/bgpd/bgp_table.c
index 53175bfcc..b75246b17 100644
--- a/bgpd/bgp_table.c
+++ b/bgpd/bgp_table.c
@@ -159,7 +159,8 @@ void bgp_table_range_lookup(const struct bgp_table *table, struct prefix *p,
if (node == NULL)
return;
- while (node->p.prefixlen <= p->prefixlen && prefix_match(&node->p, p)) {
+ while (node &&
+ node->p.prefixlen <= p->prefixlen && prefix_match(&node->p, p)) {
if (bgp_node_has_bgp_path_info_data(node)
&& node->p.prefixlen == p->prefixlen) {
matched = node;
@@ -169,14 +170,20 @@ void bgp_table_range_lookup(const struct bgp_table *table, struct prefix *p,
&p->u.prefix, node->p.prefixlen)]);
}
+ if (!node)
+ return;
+
if (matched == NULL && node->p.prefixlen <= maxlen
&& prefix_match(p, &node->p) && node->parent == NULL)
matched = node;
else if ((matched == NULL && node->p.prefixlen > maxlen) || !node->parent)
return;
- else if (matched == NULL)
+ else if (matched == NULL && node->parent)
matched = node = bgp_node_from_rnode(node->parent);
+ if (!matched)
+ return;
+
if (bgp_node_has_bgp_path_info_data(matched)) {
bgp_lock_node(matched);
listnode_add(matches, matched);