From: Renato Westphal Date: Mon, 14 Jan 2019 18:29:18 +0000 (-0200) Subject: lib: don't abort when incomplete xpath is given by the user X-Git-Tag: frr-7.1-dev~22^2~2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=9f6de29901ed93e7db721b20e861c598364fa9a2;p=mirror%2Ffrr.git 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 --- 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;