Skip to content

Commit

Permalink
lib: fix address sanitizer crash on find
Browse files Browse the repository at this point in the history
Fix the following address sanitizer crash when running the command `find`:

   ==163468==ERROR: AddressSanitizer: dynamic-stack-buffer-overflow on address 0x7fff4840fc1d at pc 0x7f4311742d11 bp 0x7fff4840fbc0 sp 0x7fff4840fb
   b0
   WRITE of size 1 at 0x7fff4840fc1d thread T0
       #0 0x7f4311742d10 in print_cmd ../lib/command.c:1541
       #1 0x7f4311746274 in cmd_find_cmds ../lib/command.c:2364
       #2 0x560b18b4c222 in find ../vtysh/vtysh.c:3732
       #3 0x7f431174043a in cmd_execute_command_real ../lib/command.c:995
       #4 0x7f43117407d3 in cmd_execute_command ../lib/command.c:1055
       #5 0x7f4311741446 in cmd_execute ../lib/command.c:1219
       #6 0x560b18b426c7 in vtysh_execute_func ../vtysh/vtysh.c:486
       #7 0x560b18b43575 in vtysh_execute ../vtysh/vtysh.c:671
       #8 0x560b18b409b4 in main ../vtysh/vtysh_main.c:721
       #9 0x7f43113c90b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
       #10 0x560b18b3e64d in _start (/usr/bin/vtysh+0x21f64d)

Signed-off-by: Rafael Zalamena <[email protected]>
  • Loading branch information
rzalamena committed Jun 7, 2021
1 parent 455d14a commit b75f5c9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -1496,7 +1496,7 @@ static void permute(struct graph_node *start, struct vty *vty)
static void print_cmd(struct vty *vty, const char *cmd)
{
int i, j, len = strlen(cmd);
char buf[len];
char buf[len + 1];
bool skip = false;

j = 0;
Expand Down

0 comments on commit b75f5c9

Please sign in to comment.