]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: don't abort when incomplete xpath is given by the user
authorRenato Westphal <renato@opensourcerouting.org>
Mon, 14 Jan 2019 18:29:18 +0000 (16:29 -0200)
committerRenato Westphal <renato@opensourcerouting.org>
Mon, 14 Jan 2019 18:33:21 +0000 (16:33 -0200)
Instead of aborting when an incomplete xpath is given to the
nb_oper_data_iterate() function, just return an error so that the
callers have a chance to treat this error. Aborting based on invalid
user input is never the right thing to do.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
lib/northbound.c

index 70d11a4a42d20e065b2b825637b64854459e7a8c..6fe612d72a2605498fbfbf5c5b4963bbbe52d20d 100644 (file)
@@ -1278,8 +1278,12 @@ int nb_oper_data_iterate(const char *xpath, struct yang_translator *translator,
                        n++;
                }
                list_keys.num = n;
-               assert(list_keys.num
-                      == ((struct lys_node_list *)dn->schema)->keys_size);
+               if (list_keys.num
+                   != ((struct lys_node_list *)dn->schema)->keys_size) {
+                       list_delete(&list_dnodes);
+                       yang_dnode_free(dnode);
+                       return NB_ERR_NOT_FOUND;
+               }
 
                /* Find the list entry pointer. */
                nn = dn->schema->priv;