diff options
author | Quentin Young <qlyoung@cumulusnetworks.com> | 2019-08-23 22:05:10 +0200 |
---|---|---|
committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2019-08-23 22:06:26 +0200 |
commit | 52038aca4e77915c3096e2877c842663b9ddff47 (patch) | |
tree | 0391644a649941e64296cdcb9731f1929d4ab76d /vtysh | |
parent | Merge pull request #4864 from donaldsharp/nullzero (diff) | |
download | frr-52038aca4e77915c3096e2877c842663b9ddff47.tar.xz frr-52038aca4e77915c3096e2877c842663b9ddff47.zip |
vtysh: fix rare crash(es)
Couple code paths end up trying to dereference vty->of which can be null
in one special case.
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'vtysh')
-rw-r--r-- | vtysh/vtysh.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index fba754f62..b053392bf 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -164,9 +164,10 @@ static int vtysh_reconnect(struct vtysh_client *vclient); static void vclient_close(struct vtysh_client *vclient) { if (vclient->fd >= 0) { - vty_out(vty, - "Warning: closing connection to %s because of an I/O error!\n", - vclient->name); + if (vty->of) + vty_out(vty, + "Warning: closing connection to %s because of an I/O error!\n", + vclient->name); close(vclient->fd); /* indicate as candidate for reconnect */ vclient->fd = VTYSH_WAS_ACTIVE; @@ -237,8 +238,11 @@ static int vtysh_client_run(struct vtysh_client *vclient, const char *line, continue; if (nread <= 0) { - vty_out(vty, "vtysh: error reading from %s: %s (%d)", - vclient->name, safe_strerror(errno), errno); + if (vty->of) + vty_out(vty, + "vtysh: error reading from %s: %s (%d)", + vclient->name, safe_strerror(errno), + errno); goto out_err; } @@ -383,7 +387,7 @@ static int vtysh_client_run_all(struct vtysh_client *head_client, rc_all = rc; } } - if (wrong_instance && !correct_instance) { + if (wrong_instance && !correct_instance && vty->of) { vty_out(vty, "%% [%s]: command ignored as it targets an instance that is not running\n", head_client->name); |