lib: copy xpaths when enqueing changes

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>
This commit is contained in:
Emanuele Di Pascale 2018-12-04 15:34:09 +01:00
parent 625b70e3da
commit 8427e0e674
2 changed files with 2 additions and 2 deletions

View 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;
}

View File

@ -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;
};