summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2019-08-30 00:15:26 +0200
committerNeels Hofmeyr <neels@hofmeyr.de>2019-08-30 00:38:01 +0200
commitf8fe48e7fb2f0fef722bcd0d4cf37f6697ae86b4 (patch)
treede5a87972b384ed64084d42c49233f3292dc653c /src
parent2d90611cb06b780b165296aa3abd1f7229d503f9 (diff)
fix: vty crash by logging during VTY_CLOSED event handling
When a VTY closes, dispatch the VTY_CLOSED signal before tearing down the VTY buffer and fd. In particular this fixes: - a crash during telnet_close_client(), invoked by the VTY_CLOSED event, which logs to DLGLOBAL and uses vty->obuf that, so far, vty_close() had already unallocated earlier (OS#4164). - the logging about closing a telnet session so far logged: DLGLOBAL INFO Closing telnet connection r=NULL<->l=NULL By dispatching the VTY_CLOSED event while the fd is still valid, we instead get the actual connection IP address and port being closed: DLGLOBAL INFO Closing telnet connection r=127.0.0.1:36708<->l=127.0.0.1:4258 Related: OS#4164 Change-Id: I1d235cbfbfb9aaf411316642c7bcfac12106df44
Diffstat (limited to 'src')
-rw-r--r--src/vty/vty.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/vty/vty.c b/src/vty/vty.c
index a96d86ce..aa23fa00 100644
--- a/src/vty/vty.c
+++ b/src/vty/vty.c
@@ -205,6 +205,9 @@ void vty_close(struct vty *vty)
{
int i;
+ /* VTY_CLOSED is handled by the telnet_interface */
+ vty_event(VTY_CLOSED, vty->fd, vty);
+
if (vty->obuf) {
/* Flush buffer. */
buffer_flush_all(vty->obuf, vty->fd);
@@ -236,9 +239,6 @@ void vty_close(struct vty *vty)
/* Check configure. */
vty_config_unlock(vty);
- /* VTY_CLOSED is handled by the telnet_interface */
- vty_event(VTY_CLOSED, vty->fd, vty);
-
/* OK free vty. */
talloc_free(vty);
}