vtysh: Crash during show running-config

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>
This commit is contained in:
saravanank 2020-03-26 17:36:37 -07:00
parent 7f2ccbe562
commit 9934e1c9b8

View File

@ -231,8 +231,13 @@ int vty_out(struct vty *vty, const char *format, ...)
strlen(filtered));
break;
case VTY_SHELL:
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: