From bf743bf85c6e7222358d8941359ea937782a595a Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Fri, 18 Jan 2019 19:14:27 +0000 Subject: [PATCH] Uppity: properly support _POSIX_VDISABLE in tty modes. The SSH wire protocol for tty modes corresponding to control characters (e.g. configuring what Ctrl-Foo you can press to generate SIGINT or SIGQUIT) specifies (RFC 4254 section 8, under VINTR, saying 'similarly for the other characters') that you should send the value 255 on the wire if you want _no_ character code to map to the action in question. But in the API, that's indicated by setting the appropriate field of 'struct termios' to _POSIX_VDISABLE, which is a platform-dependent value and varies between (at least) Linux and *BSD. On the client side, Unix Plink has always known this: when it copies the local termios settings into a struct ssh_ttymodes to be sent on the wire, it checks for _POSIX_VDISABLE and replaces it with 255. But uxpty.c, mapping ssh_ttymodes back to termios for Uppity's pty sessions, wasn't making the reverse transformation. --- unix/uxpty.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/unix/uxpty.c b/unix/uxpty.c index 97953c6e..47b5ef51 100644 --- a/unix/uxpty.c +++ b/unix/uxpty.c @@ -816,9 +816,13 @@ static void pty_uxsel_setup(Pty *pty) static void copy_ttymodes_into_termios( struct termios *attrs, struct ssh_ttymodes modes) { -#define TTYMODE_CHAR(name, ssh_opcode, cc_index) { \ - if (modes.have_mode[ssh_opcode]) \ - attrs->c_cc[cc_index] = modes.mode_val[ssh_opcode]; \ +#define TTYMODE_CHAR(name, ssh_opcode, cc_index) { \ + if (modes.have_mode[ssh_opcode]) { \ + unsigned value = modes.mode_val[ssh_opcode]; \ + /* normalise wire value of 255 to local _POSIX_VDISABLE */ \ + attrs->c_cc[cc_index] = (value == 255 ? \ + _POSIX_VDISABLE : value); \ + } \ } #define TTYMODE_FLAG(flagval, ssh_opcode, field, flagmask) { \