From dfe82ee2e48d2c9f2ed3045e673ed51e271a00a6 Mon Sep 17 00:00:00 2001 From: Rob Sanders Date: Tue, 10 Mar 2020 13:29:25 -0400 Subject: [PATCH] Fix segfault issue during tab/help processing. --- Makefile | 2 +- libcli.c | 7 ++++++- libcli.spec | 8 ++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index c0b2994..e90e144 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ PREFIX = /usr/local MAJOR = 1 MINOR = 10 -REVISION = 3 +REVISION = 4 LIB = libcli.so LIB_STATIC = libcli.a diff --git a/libcli.c b/libcli.c index 2df266c..cca6249 100644 --- a/libcli.c +++ b/libcli.c @@ -933,6 +933,7 @@ void cli_get_completions(struct cli_def *cli, const char *command, char lastchar if (c) { // Advance past first word of stage i++; + stage->command = c; stage->first_unmatched = i; if (c->optargs) { cli_int_parse_optargs(cli, stage, c, lastchar, comphelp); @@ -940,6 +941,10 @@ void cli_get_completions(struct cli_def *cli, const char *command, char lastchar // Special case for getting help with no defined optargs.... comphelp->num_entries = -1; } + if (stage->status) { + // if we had an error here we need to redraw the commandline + cli_reprompt(cli); + } } cli_int_free_pipeline(pipeline); @@ -3310,7 +3315,7 @@ static void cli_int_parse_optargs(struct cli_def *cli, struct cli_pipeline_stage if (num_candidates > 1 && (lastchar == '\0' || word_idx < (stage->num_words - 1))) { stage->error_word = stage->words[word_idx]; stage->status = CLI_AMBIGUOUS; - cli_error(cli, "Ambiguous option/argument for command %s", stage->command->command); + cli_error(cli, "\nAmbiguous option/argument for command %s", stage->command->command); goto done; } diff --git a/libcli.spec b/libcli.spec index f88a06d..fa2bc94 100644 --- a/libcli.spec +++ b/libcli.spec @@ -1,4 +1,4 @@ -Version: 1.10.3 +Version: 1.10.4 Summary: Cisco-like telnet command-line library Name: libcli Release: 1 @@ -67,7 +67,11 @@ rm -rf $RPM_BUILD_ROOT %defattr(-, root, root) %changelog -* Fri Jan 10 2020 Rob Sanders 10.10.3-1 +* Tue Mar 3 2020 Rob Sanders 1.10.4-1 +- Fix segfault issue found during tab/help processing +- Minor fix of version on previous changelog record + +* Fri Jan 10 2020 Rob Sanders 1.10.3-1 - Minor cosmetic change to how help messages are generated, minor edits to some comments, minor cosmetic change to clitest demo code