diff options
| author | David Lamparter <equinox@opensourcerouting.org> | 2016-12-15 23:53:02 +0100 | 
|---|---|---|
| committer | David Lamparter <equinox@opensourcerouting.org> | 2016-12-16 20:42:01 +0100 | 
| commit | 53d5ec367882becf01cf3c484f3570f10a11618d (patch) | |
| tree | 2c556808b412b073c927fe530b0b4bf7a3640f83 /lib/command.c | |
| parent | 7d5718c140611ae125dfab56b94f6a96e19b5922 (diff) | |
lib: parser: fix SEGV when Tab hits non-WORD_TKN
If <Tab> processing finds that there is only 1 candidate, but that
candidate is not a WORD_TKN that we can tab-complete on, the status
would remain at CMD_COMPLETE_FULL_MATCH, but the resulting list of
possible completions is empty.
This then SEGVs in lib/vty.c where it tries to access the first element
of the list, assuming FULL_MATCH always has 1 element there...
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Cc: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'lib/command.c')
| -rw-r--r-- | lib/command.c | 13 | 
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/command.c b/lib/command.c index 8d5493ca56..a93f3a55e8 100644 --- a/lib/command.c +++ b/lib/command.c @@ -686,6 +686,19 @@ cmd_complete_command (vector vline, struct vty *vty, int *status)      }      vector_free (initial_comps); +    // since we filtered results, we need to re-set status code +    switch (vector_active (comps)) +    { +      case 0: +        *status = CMD_ERR_NO_MATCH; +        break; +      case 1: +        *status = CMD_COMPLETE_FULL_MATCH; +        break; +      default: +        *status = CMD_COMPLETE_LIST_MATCH; +    } +      // copy completions text into an array of char*      ret = XMALLOC (MTYPE_TMP, (vector_active (comps)+1) * sizeof (char *));      unsigned int i;  | 
