]> git.puffer.fish Git - mirror/frr.git/commitdiff
isisd: fix crash in the adjacency get_next() NB callback
authorRenato Westphal <renato@opensourcerouting.org>
Thu, 7 May 2020 15:41:12 +0000 (12:41 -0300)
committerRenato Westphal <renato@opensourcerouting.org>
Sat, 16 May 2020 02:47:43 +0000 (23:47 -0300)
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>
isisd/isis_nb_state.c

index 1e44e60ee0529eb3f44384ebaf3048db712bef60..1a10b8a8cf6600943d50dfe1a2a889398065dcb0 100644 (file)
@@ -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;
                }