summaryrefslogtreecommitdiff
path: root/lib/command.c
diff options
context:
space:
mode:
authorRafael Zalamena <rzalamena@opensourcerouting.org>2021-06-07 11:02:16 -0300
committerRafael Zalamena <rzalamena@opensourcerouting.org>2021-06-07 11:14:25 -0300
commit77af3a34ba8ef11380f23d4e7e9ce7c097ea8b63 (patch)
tree218bf361aef4d48bcb84b5ddc55b985e25a3e9fe /lib/command.c
parent455d14ae317c461febc02d3731bf8691c2f2ee5f (diff)
lib: fix address sanitizer crash on `find`
Fix the following address sanitizer crash when running the command `find`: ERROR: AddressSanitizer: dynamic-stack-buffer-overflow WRITE of size 1 at 0x7fff4840fc1d thread T0 0 in print_cmd ../lib/command.c:1541 1 in cmd_find_cmds ../lib/command.c:2364 2 in find ../vtysh/vtysh.c:3732 3 in cmd_execute_command_real ../lib/command.c:995 4 in cmd_execute_command ../lib/command.c:1055 5 in cmd_execute ../lib/command.c:1219 6 in vtysh_execute_func ../vtysh/vtysh.c:486 7 in vtysh_execute ../vtysh/vtysh.c:671 8 in main ../vtysh/vtysh_main.c:721 9 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2) 10 in _start (/usr/bin/vtysh+0x21f64d) Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
Diffstat (limited to 'lib/command.c')
-rw-r--r--lib/command.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/command.c b/lib/command.c
index 008f98a34c..a19d392f38 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -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;