[quagga-dev,15566,15/16] vtysh: handle case if there is no match in "write terminal $daemon"

Message ID 1465927630-27768-15-git-send-email-chris@opensourcerouting.org
State Under Review
Headers show
Series
  • [quagga-dev,15552,01/16] zebra: fix null pointer dereference in zsend_ipv4_nexthop_lookup_mrib
Related show

Commit Message

Christian Franke June 14, 2016, 6:07 p.m.
From: Christian Franke <nobody@nowhere.ws>

While the DEFUN should match the list of clients registered in
vtysh, it seems better to handle the case explicitly instead of
relying on the client list and the DEFUN signature being in sync.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
---
 vtysh/vtysh.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Donald Sharp June 16, 2016, 1:46 p.m. | #1
Acked-by: Donald Sharp <sharpd@cumulusnetworks.com>

On Tue, Jun 14, 2016 at 2:07 PM, Christian Franke
<chris@opensourcerouting.org> wrote:
> From: Christian Franke <nobody@nowhere.ws>
>
> While the DEFUN should match the list of clients registered in
> vtysh, it seems better to handle the case explicitly instead of
> relying on the client list and the DEFUN signature being in sync.
>
> Signed-off-by: Christian Franke <chris@opensourcerouting.org>
> ---
>  vtysh/vtysh.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c
> index 63b596a..625ab1c 100644
> --- a/vtysh/vtysh.c
> +++ b/vtysh/vtysh.c
> @@ -1840,6 +1840,9 @@ DEFUN (vtysh_write_terminal_daemon,
>         break;
>      }
>
> +  if (i == array_size(vtysh_client))
> +    return CMD_ERR_NO_MATCH;
> +
>    ret = vtysh_client_execute(&vtysh_client[i], "show running-config\n", stdout);
>
>    return ret;
> --
> 2.8.0
>
>
> _______________________________________________
> Quagga-dev mailing list
> Quagga-dev@lists.quagga.net
> https://lists.quagga.net/mailman/listinfo/quagga-dev

Patch hide | download patch | download mbox

diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c
index 63b596a..625ab1c 100644
--- a/vtysh/vtysh.c
+++ b/vtysh/vtysh.c
@@ -1840,6 +1840,9 @@  DEFUN (vtysh_write_terminal_daemon,
 	break;
     }
 
+  if (i == array_size(vtysh_client))
+    return CMD_ERR_NO_MATCH;
+
   ret = vtysh_client_execute(&vtysh_client[i], "show running-config\n", stdout);
 
   return ret;