diff options
| author | Christian Hopps <chopps@labn.net> | 2025-02-26 13:34:59 +0000 |
|---|---|---|
| committer | Christian Hopps <chopps@labn.net> | 2025-03-03 15:44:33 +0000 |
| commit | a64ecbadcc83fd1040d9c355cb1bc3a9d03a0fc7 (patch) | |
| tree | 6f0e9acf848f6faf25259e52829b3c1b6bde00c8 /lib/yang.c | |
| parent | 37893e4421d900eaaab3891b02b7e6b2080c21c6 (diff) | |
lib: nb: fix bug with oper-state query on list data
The capacity of the xpath string was not guaranteed to be sufficient to hold all
the key predicates and so would truncate. Calculate the required space and
guarantee that it is available.
Signed-off-by: Christian Hopps <chopps@labn.net>
Diffstat (limited to 'lib/yang.c')
| -rw-r--r-- | lib/yang.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/yang.c b/lib/yang.c index dd48d8861b..0e2f78979a 100644 --- a/lib/yang.c +++ b/lib/yang.c @@ -1357,9 +1357,22 @@ uint32_t yang_get_list_elements_count(const struct lyd_node *node) } while (node); return count; } +int yang_get_key_pred_strlen(const struct lysc_node *snode, const struct yang_list_keys *keys) +{ + const struct lysc_node_leaf *skey; + size_t len = 0; + size_t i = 0; + + LY_FOR_KEYS (snode, skey) { + /* [%s='%s'] */ + len += 5 + strlen(skey->name) + strlen(keys->key[i]); + i++; + } + return len; +} -int yang_get_key_preds(char *s, const struct lysc_node *snode, - struct yang_list_keys *keys, ssize_t space) +int yang_get_key_preds(char *s, const struct lysc_node *snode, const struct yang_list_keys *keys, + ssize_t space) { const struct lysc_node_leaf *skey; ssize_t len2, len = 0; |
