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 <renato@opensourcerouting.org>
This commit is contained in:
Renato Westphal 2020-05-07 12:41:12 -03:00
parent a6943f9dab
commit e3c19b8145

View File

@ -36,7 +36,7 @@ const void *lib_interface_isis_adjacencies_adjacency_get_next(
{ {
struct interface *ifp; struct interface *ifp;
struct isis_circuit *circuit; struct isis_circuit *circuit;
struct isis_adjacency *adj, *adj_next = NULL; struct isis_adjacency *adj = NULL, *adj_next = NULL;
struct list *list; struct list *list;
struct listnode *node, *node_next; struct listnode *node, *node_next;
@ -54,17 +54,20 @@ const void *lib_interface_isis_adjacencies_adjacency_get_next(
case CIRCUIT_T_BROADCAST: case CIRCUIT_T_BROADCAST:
for (int level = ISIS_LEVEL1; level <= ISIS_LEVELS; for (int level = ISIS_LEVEL1; level <= ISIS_LEVELS;
level++) { level++) {
adj = listnode_head( struct list *adjdb;
circuit->u.bc.adjdb[level - 1]);
if (adj) adjdb = circuit->u.bc.adjdb[level - 1];
break; if (adjdb) {
adj = listnode_head(adjdb);
if (adj)
break;
}
} }
break; break;
case CIRCUIT_T_P2P: case CIRCUIT_T_P2P:
adj = circuit->u.p2p.neighbor; adj = circuit->u.p2p.neighbor;
break; break;
default: default:
adj = NULL;
break; break;
} }