From e3c19b8145b2a45b1591cd72d19a5a913b61c921 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Thu, 7 May 2020 12:41:12 -0300 Subject: [PATCH] isisd: fix crash in the adjacency get_next() NB callback Add a null check to solve the problem (circuit->u.bc.adjdb[level - 1] is guaranteed to be non-null only on L1/L2 areas). Signed-off-by: Renato Westphal --- isisd/isis_nb_state.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/isisd/isis_nb_state.c b/isisd/isis_nb_state.c index 1e44e60ee0..1a10b8a8cf 100644 --- a/isisd/isis_nb_state.c +++ b/isisd/isis_nb_state.c @@ -36,7 +36,7 @@ const void *lib_interface_isis_adjacencies_adjacency_get_next( { struct interface *ifp; struct isis_circuit *circuit; - struct isis_adjacency *adj, *adj_next = NULL; + struct isis_adjacency *adj = NULL, *adj_next = NULL; struct list *list; struct listnode *node, *node_next; @@ -54,17 +54,20 @@ const void *lib_interface_isis_adjacencies_adjacency_get_next( case CIRCUIT_T_BROADCAST: for (int level = ISIS_LEVEL1; level <= ISIS_LEVELS; level++) { - adj = listnode_head( - circuit->u.bc.adjdb[level - 1]); - if (adj) - break; + struct list *adjdb; + + adjdb = circuit->u.bc.adjdb[level - 1]; + if (adjdb) { + adj = listnode_head(adjdb); + if (adj) + break; + } } break; case CIRCUIT_T_P2P: adj = circuit->u.p2p.neighbor; break; default: - adj = NULL; break; } -- 2.39.5