diff options
| author | Quentin Young <qlyoung@cumulusnetworks.com> | 2018-05-29 17:13:51 +0000 |
|---|---|---|
| committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2018-06-06 16:16:12 +0000 |
| commit | 5d806ec6e0bce5f1cd32b0d5386c1ad97c31c1f8 (patch) | |
| tree | c025730971c6c8eb3351b439659a8a36b0e0369d /lib/command.c | |
| parent | 62bece44494e5b7aefb5102bd1109e1e1376c3b3 (diff) | |
lib: fix static analysis issues, use regfree()
* Fix potential NULL dereference
* Fix use of uninitialized value
* Fix leaking memory by not freeing regex_t
* Fix extra \n when using empty regex filter
* Clean up still-reachable hook memory
* Handle nonexistent pager
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'lib/command.c')
| -rw-r--r-- | lib/command.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/command.c b/lib/command.c index 3bd578cf01..edf7348ba7 100644 --- a/lib/command.c +++ b/lib/command.c @@ -1198,16 +1198,22 @@ static int handle_pipe_action(struct vty *vty, const char *cmd_in, if (strmatch(token, "include")) { /* the remaining text should be a regexp */ char *regexp = working; + + if (!regexp) { + vty_out(vty, "%% Need a regexp to filter with\n"); + goto fail; + } + bool succ = vty_set_include(vty, regexp); if (!succ) { - vty_out(vty, "%% Bad regexp '%s'", regexp); + vty_out(vty, "%% Bad regexp '%s'\n", regexp); goto fail; } *cmd_out = XSTRDUP(MTYPE_TMP, cmd_in); *(strstr(*cmd_out, "|")) = '\0'; } else { - vty_out(vty, "%% Unknown action '%s'", token); + vty_out(vty, "%% Unknown action '%s'\n", token); goto fail; } @@ -2892,6 +2898,9 @@ void cmd_terminate() { struct cmd_node *cmd_node; + hook_unregister(cmd_execute, handle_pipe_action); + hook_unregister(cmd_execute_done, handle_pipe_action_done); + if (cmdvec) { for (unsigned int i = 0; i < vector_active(cmdvec); i++) if ((cmd_node = vector_slot(cmdvec, i)) != NULL) { |
