X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/5f95fdf1635ee92d80711c264f3dd2fa27f7d5c1..6226c9390d23d6868edde63b9568891cd88631cc:/telnet.c diff --git a/telnet.c b/telnet.c index 54b9a7c7..0d32f8c2 100644 --- a/telnet.c +++ b/telnet.c @@ -1,3 +1,7 @@ +/* + * Telnet backend. + */ + #include #include @@ -394,9 +398,12 @@ static void proc_rec_opt(Telnet telnet, int cmd, int option) } /* * If we reach here, the option was one we weren't prepared to - * cope with. So send a negative ack. + * cope with. If the request was positive (WILL or DO), we send + * a negative ack to indicate refusal. If the request was + * negative (WONT / DONT), we must do nothing. */ - send_opt(telnet, (cmd == WILL ? DONT : WONT), option); + if (cmd == WILL || cmd == DO) + send_opt(telnet, (cmd == WILL ? DONT : WONT), option); } static void process_subneg(Telnet telnet) @@ -1012,10 +1019,10 @@ static const struct telnet_special *telnet_get_specials(void *handle) return specials; } -static Socket telnet_socket(void *handle) +static int telnet_connected(void *handle) { Telnet telnet = (Telnet) handle; - return telnet->s; + return telnet->s != NULL; } static int telnet_sendok(void *handle) @@ -1078,7 +1085,7 @@ Backend telnet_backend = { telnet_size, telnet_special, telnet_get_specials, - telnet_socket, + telnet_connected, telnet_exitcode, telnet_sendok, telnet_ldisc,