From 8427e0e67445d42dbcc4d6ad8ba018865a4532f2 Mon Sep 17 00:00:00 2001 From: Emanuele Di Pascale Date: Tue, 4 Dec 2018 15:34:09 +0100 Subject: [PATCH] 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 --- lib/northbound_cli.c | 2 +- lib/vty.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/northbound_cli.c b/lib/northbound_cli.c index d685a4e7c2..acde0ead02 100644 --- a/lib/northbound_cli.c +++ b/lib/northbound_cli.c @@ -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; } diff --git a/lib/vty.h b/lib/vty.h index ad4dc273b9..79b1bd5e93 100644 --- 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; };