]> git.proxmox.com Git - mirror_frr.git/commitdiff
lib: fix address sanitizer crash on `find`
authorRafael Zalamena <rzalamena@opensourcerouting.org>
Mon, 7 Jun 2021 14:02:16 +0000 (11:02 -0300)
committerRafael Zalamena <rzalamena@opensourcerouting.org>
Mon, 7 Jun 2021 14:14:25 +0000 (11:14 -0300)
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>
lib/command.c

index 008f98a34cb73467d2c28692256293f658b72ebd..a19d392f385f0e7633efb2ed82e7f4751ec38d78 100644 (file)
@@ -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;