]> git.puffer.fish Git - mirror/frr.git/commitdiff
vtysh: Crash during show running-config 6101/head
authorsaravanank <saravanank@vmware.com>
Fri, 27 Mar 2020 00:36:37 +0000 (17:36 -0700)
committersaravanank <saravanank@vmware.com>
Fri, 27 Mar 2020 00:36:37 +0000 (17:36 -0700)
RCA:
when client is killed, show running-config command crashes vtysh.
vtysh_client_config function temporarily makes vty->of which is standard output file
pointer to null inorder to suppress output to user.
This call further tries to communicate with each client and when the client
is terminated, socket call fails and hits the exception path to print the
connection has failed using vty_out.
vty_out crashes because vtysh_client_config has temporarily made vty->of
pointer to NULL to supress o/p to user.

Fix:
vty_out function should check for the sanity of vty->of pointer.
If it doesn't exist, this must have hit exception path, so use the
vty->saved_of if exists.

Signed-off-by: Saravanan K <saravanank@vmware.com>
lib/vty.c

index 4dd6ec1b351fe8188f3920292b55a8905c50744c..8056236de9e1a7475564d2fe6ff5e3fd77a32754 100644 (file)
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -231,8 +231,13 @@ int vty_out(struct vty *vty, const char *format, ...)
                                strlen(filtered));
                break;
        case VTY_SHELL:
-               fprintf(vty->of, "%s", filtered);
-               fflush(vty->of);
+               if (vty->of) {
+                       fprintf(vty->of, "%s", filtered);
+                       fflush(vty->of);
+               } else if (vty->of_saved) {
+                       fprintf(vty->of_saved, "%s", filtered);
+                       fflush(vty->of_saved);
+               }
                break;
        case VTY_SHELL_SERV:
        case VTY_FILE: