From 9f6de29901ed93e7db721b20e861c598364fa9a2 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Mon, 14 Jan 2019 16:29:18 -0200 Subject: [PATCH] lib: don't abort when incomplete xpath is given by the user 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 --- lib/northbound.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/northbound.c b/lib/northbound.c index 70d11a4a42..6fe612d72a 100644 --- a/lib/northbound.c +++ b/lib/northbound.c @@ -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; -- 2.39.5