From 9f2e1e6e03043f551b1a449991ea45d954204808 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Wed, 21 Dec 2022 15:13:46 +0000 Subject: [PATCH] Prevent sending double-EOF in raw backend. You can't call sk_write_eof() twice on the same socket, because the second one will fail an assertion. Instead, you're supposed to know you've already sent EOF, and not try to send it again. The call to sk_write_eof() in raw_special (triggered by pressing ^D in GUI PuTTY, for example) sets the flag raw->sent_socket_eof in an attempt to prevent this. But it doesn't _check_ that flag, so a second press of ^D can reach that assertion failure. --- otherbackends/raw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/otherbackends/raw.c b/otherbackends/raw.c index c9a32e05..c95db970 100644 --- a/otherbackends/raw.c +++ b/otherbackends/raw.c @@ -285,7 +285,8 @@ static void raw_special(Backend *be, SessionSpecialCode code, int arg) { Raw *raw = container_of(be, Raw, backend); if (code == SS_EOF && raw->s) { - sk_write_eof(raw->s); + if (!raw->sent_socket_eof) + sk_write_eof(raw->s); raw->sent_socket_eof= true; raw_check_close(raw); }