From 1d10976c161cfb2e7ec114b7c72885e6f195a3d5 Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Tue, 16 Aug 2005 21:32:09 +1000 Subject: [PATCH] - (djm) [ttymodes.c] bugzilla #1054: Fix encoding of _POSIX_VDISABLE, from Jacob Nevins; ok dtucker@ --- ChangeLog | 6 +++++- ttymodes.c | 30 ++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1eba83b1c..e77dd1f4d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +20050816 + - (djm) [ttymodes.c] bugzilla #1054: Fix encoding of _POSIX_VDISABLE, + from Jacob Nevins; ok dtucker@ + 20050815 - (tim) [sftp.c] wrap el_end() in #ifdef USE_LIBEDIT - (tim) [configure.ac] corrections to libedit tests. Report and patches @@ -2937,4 +2941,4 @@ - (djm) Trim deprecated options from INSTALL. Mention UsePAM - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu -$Id: ChangeLog,v 1.3873 2005/08/16 00:48:40 tim Exp $ +$Id: ChangeLog,v 1.3874 2005/08/16 11:32:09 djm Exp $ diff --git a/ttymodes.c b/ttymodes.c index c32e213a4..cf4c7d5c6 100644 --- a/ttymodes.c +++ b/ttymodes.c @@ -240,6 +240,32 @@ baud_to_speed(int baud) } } +/* + * Encode a special character into SSH line format. + */ +static u_int +special_char_encode(cc_t c) +{ +#ifdef _POSIX_VDISABLE + if (c == _POSIX_VDISABLE) + return 255; +#endif /* _POSIX_VDISABLE */ + return c; +} + +/* + * Decode a special character from SSH line format. + */ +static cc_t +special_char_decode(u_int c) +{ +#ifdef _POSIX_VDISABLE + if (c == 255) + return _POSIX_VDISABLE; +#endif /* _POSIX_VDISABLE */ + return c; +} + /* * Encodes terminal modes for the terminal referenced by fd * or tiop in a portable manner, and appends the modes to a packet @@ -287,7 +313,7 @@ tty_make_modes(int fd, struct termios *tiop) #define TTYCHAR(NAME, OP) \ debug3("tty_make_modes: %d %d", OP, tio.c_cc[NAME]); \ buffer_put_char(&buf, OP); \ - put_arg(&buf, tio.c_cc[NAME]); + put_arg(&buf, special_char_encode(tio.c_cc[NAME])); #define TTYMODE(NAME, FIELD, OP) \ debug3("tty_make_modes: %d %d", OP, ((tio.FIELD & NAME) != 0)); \ @@ -375,7 +401,7 @@ tty_parse_modes(int fd, int *n_bytes_ptr) #define TTYCHAR(NAME, OP) \ case OP: \ n_bytes += arg_size; \ - tio.c_cc[NAME] = get_arg(); \ + tio.c_cc[NAME] = special_char_decode(get_arg()); \ debug3("tty_parse_modes: %d %d", OP, tio.c_cc[NAME]); \ break; #define TTYMODE(NAME, FIELD, OP) \