From 7a816f90e7087d8738901a40c03df08f50c55fcc Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 25 Sep 2026 10:37:05 +0000 Subject: [PATCH] Discard keys if there is no session, fixes crash reported by Artyom Pertsovsky. --- tty-keys.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tty-keys.c b/tty-keys.c index 8462e0d9b..7125dcaf7 100644 --- a/tty-keys.c +++ b/tty-keys.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty-keys.c,v 1.214 2026/08/18 09:01:20 nicm Exp $ */ +/* $OpenBSD: tty-keys.c,v 1.215 2026/09/25 10:37:05 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -761,6 +761,16 @@ tty_keys_next(struct tty *tty) return (0); log_debug("%s: keys are %zu (%.*s)", c->name, len, (int)len, buf); + /* If the client has no session, there is nowhere to send input. */ + if (c->session == NULL) { + log_debug("%s: discard keys with no session", c->name); + if (event_initialized(&tty->key_timer)) + evtimer_del(&tty->key_timer); + tty->flags &= ~TTY_TIMER; + evbuffer_drain(tty->in, len); + return (1); + } + /* Is this a clipboard response? */ switch (tty_keys_clipboard(tty, buf, len, &size)) { case 0: /* yes */