diff options
author | Donald Sharp <sharpd@nvidia.com> | 2023-08-07 21:57:29 +0200 |
---|---|---|
committer | Donald Sharp <sharpd@nvidia.com> | 2023-08-07 21:57:29 +0200 |
commit | 296645fc78a4147fdea81f174cb222dd633722c1 (patch) | |
tree | caa9240f377d3dddd040d6609b26e01e58b8c2b8 /ospfd | |
parent | Merge pull request #14151 from opensourcerouting/fix/improve_addpath_selected... (diff) | |
download | frr-296645fc78a4147fdea81f174cb222dd633722c1.tar.xz frr-296645fc78a4147fdea81f174cb222dd633722c1.zip |
ospfd: Ensure listnode returns are usable
Coverity is complaining that listnode can return a NULL
value and thus FRR could derefence the returned value.
Since this is not crashing we know that this is not happening
in the wild. Let's make this an assert or check that it is
legal to use the value.
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'ospfd')
-rw-r--r-- | ospfd/ospf_ti_lfa.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/ospfd/ospf_ti_lfa.c b/ospfd/ospf_ti_lfa.c index 07fc50394..f9bc2b4dd 100644 --- a/ospfd/ospf_ti_lfa.c +++ b/ospfd/ospf_ti_lfa.c @@ -64,6 +64,7 @@ ospf_ti_lfa_find_p_node(struct vertex *pc_node, struct p_space *p_space, struct vertex_parent *pc_vertex_parent; curr_node = listnode_lookup(q_space->pc_path, pc_node); + assert(curr_node); pc_node_parent = listgetdata(curr_node->next); q_space->p_node_info->type = OSPF_TI_LFA_UNDEFINED_NODE; @@ -105,6 +106,7 @@ static void ospf_ti_lfa_find_q_node(struct vertex *pc_node, struct vertex_parent *pc_vertex_parent; curr_node = listnode_lookup(q_space->pc_path, pc_node); + assert(curr_node); next_node = curr_node->next; pc_node_parent = listgetdata(next_node); pc_vertex_parent = @@ -219,7 +221,7 @@ static struct list *ospf_ti_lfa_cut_out_pc_path(struct list *pc_vertex_list, current_listnode = listnode_lookup(pc_path, current_vertex); /* Note that the post-convergence paths are reversed. */ - for (;;) { + while (current_listnode) { current_vertex = listgetdata(current_listnode); listnode_add(inner_pc_path, current_vertex); @@ -268,6 +270,7 @@ static void ospf_ti_lfa_generate_inner_label_stack( end_label = MPLS_INVALID_LABEL; if (p_node_info->node->id.s_addr == p_space->root->id.s_addr) { pc_p_node = listnode_lookup(q_space->pc_path, p_space->pc_spf); + assert(pc_p_node); start_vertex = listgetdata(pc_p_node->prev); start_label = ospf_sr_get_adj_sid_by_id(&p_node_info->node->id, &start_vertex->id); @@ -275,6 +278,7 @@ static void ospf_ti_lfa_generate_inner_label_stack( if (q_node_info->node->id.s_addr == q_space->root->id.s_addr) { pc_q_node = listnode_lookup(q_space->pc_path, listnode_head(q_space->pc_path)); + assert(pc_q_node); end_vertex = listgetdata(pc_q_node->next); end_label = ospf_sr_get_adj_sid_by_id(&end_vertex->id, &q_node_info->node->id); |