diff options
| author | Christian Hopps <chopps@labn.net> | 2025-02-26 13:34:59 +0000 |
|---|---|---|
| committer | Christian Hopps <chopps@labn.net> | 2025-02-26 13:38:42 +0000 |
| commit | 656c4692a0f1bef9c213dda465d17a5455ea9b3a (patch) | |
| tree | 958ee1737f0effb426f131297e3fe1429c363d21 /lib/northbound_oper.c | |
| parent | bd68a01d9a52383175474e534d36c99cd4b2c242 (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/northbound_oper.c')
| -rw-r--r-- | lib/northbound_oper.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/northbound_oper.c b/lib/northbound_oper.c index 5c2d3ed8c8..ad495b6f9c 100644 --- a/lib/northbound_oper.c +++ b/lib/northbound_oper.c @@ -1723,8 +1723,9 @@ static enum nb_error __walk(struct nb_op_yield_state *ys, bool is_resume) */ len = darr_strlen(ys->xpath); if (ni->keys.num) { - yang_get_key_preds(ys->xpath + len, sib, - &ni->keys, + darr_ensure_avail(ys->xpath, + yang_get_key_pred_strlen(sib, &ni->keys) + 1); + yang_get_key_preds(ys->xpath + len, sib, &ni->keys, darr_cap(ys->xpath) - len); } else { /* add a position predicate (1s based?) */ |
