]> git.proxmox.com Git - mirror_frr.git/commitdiff
lib: copy xpaths when enqueing changes
authorEmanuele Di Pascale <emanuele@voltanet.io>
Tue, 4 Dec 2018 14:34:09 +0000 (15:34 +0100)
committerEmanuele Di Pascale <emanuele@voltanet.io>
Tue, 18 Dec 2018 14:15:26 +0000 (15:15 +0100)
Just copying th const char* of the xpath means that if we
are enqueing multiple changes from a buffer, the last xpath
addedd will overwrite all of the previous references.
Copying the xpath to a buffer simplifies the API when
retrofitting the commands.

Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
lib/northbound_cli.c
lib/vty.h

index d685a4e7c282b0ade78a30f2e8c16e418bcd224e..acde0ead025ac47d62750a6baff0480a06995cd0 100644 (file)
@@ -71,7 +71,7 @@ void nb_cli_enqueue_change(struct vty *vty, const char *xpath,
        }
 
        change = &vty->cfg_changes[vty->num_cfg_changes++];
-       change->xpath = xpath;
+       strlcpy(change->xpath, xpath, sizeof(change->xpath));
        change->operation = operation;
        change->value = value;
 }
index ad4dc273b971ca31d0bed739c1df7584f9043dac..79b1bd5e9311aee3d44d0e3947d6f1e294e287f5 100644 (file)
--- a/lib/vty.h
+++ b/lib/vty.h
@@ -43,7 +43,7 @@ struct vty_error {
 };
 
 struct vty_cfg_change {
-       const char *xpath;
+       char xpath[XPATH_MAXLEN];
        enum nb_operation operation;
        const char *value;
 };