]> andersk Git - gssapi-openssh.git/blobdiff - openssh/ttymodes.c
http://www.sxw.org.uk/computing/patches/openssh-4.2p1-gsskex-20050926-2.patch
[gssapi-openssh.git] / openssh / ttymodes.c
index 8afdff1a4565bf45d0f07d77610cd65751cf33bb..cf4c7d5c6c83e1130e202e52e16f7924b7bac28a 100644 (file)
@@ -43,7 +43,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: ttymodes.c,v 1.17 2002/03/19 10:49:35 markus Exp $");
+RCSID("$OpenBSD: ttymodes.c,v 1.19 2003/04/08 20:21:29 itojun Exp $");
 
 #include "packet.h"
 #include "log.h"
@@ -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
@@ -267,7 +293,7 @@ tty_make_modes(int fd, struct termios *tiop)
 
        if (tiop == NULL) {
                if (tcgetattr(fd, &tio) == -1) {
-                       log("tcgetattr: %.100s", strerror(errno));
+                       logit("tcgetattr: %.100s", strerror(errno));
                        goto end;
                }
        } else
@@ -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)); \
@@ -307,7 +333,6 @@ end:
        else
                packet_put_raw(buffer_ptr(&buf), buffer_len(&buf));
        buffer_free(&buf);
-       return;
 }
 
 /*
@@ -342,7 +367,7 @@ tty_parse_modes(int fd, int *n_bytes_ptr)
         * modes, they will initially have reasonable values.
         */
        if (tcgetattr(fd, &tio) == -1) {
-               log("tcgetattr: %.100s", strerror(errno));
+               logit("tcgetattr: %.100s", strerror(errno));
                failure = -1;
        }
 
@@ -376,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) \
@@ -421,7 +446,7 @@ tty_parse_modes(int fd, int *n_bytes_ptr)
                                         * left in the packet; hopefully there is nothing
                                         * more coming after the mode data.
                                         */
-                                       log("parse_tty_modes: unknown opcode %d", opcode);
+                                       logit("parse_tty_modes: unknown opcode %d", opcode);
                                        goto set;
                                }
                        } else {
@@ -437,7 +462,7 @@ tty_parse_modes(int fd, int *n_bytes_ptr)
                                        (void) packet_get_int();
                                        break;
                                } else {
-                                       log("parse_tty_modes: unknown opcode %d", opcode);
+                                       logit("parse_tty_modes: unknown opcode %d", opcode);
                                        goto set;
                                }
                        }
@@ -447,7 +472,7 @@ tty_parse_modes(int fd, int *n_bytes_ptr)
 set:
        if (*n_bytes_ptr != n_bytes) {
                *n_bytes_ptr = n_bytes;
-               log("parse_tty_modes: n_bytes_ptr != n_bytes: %d %d",
+               logit("parse_tty_modes: n_bytes_ptr != n_bytes: %d %d",
                    *n_bytes_ptr, n_bytes);
                return;         /* Don't process bytes passed */
        }
@@ -456,6 +481,5 @@ set:
 
        /* Set the new modes for the terminal. */
        if (tcsetattr(fd, TCSANOW, &tio) == -1)
-               log("Setting tty modes failed: %.100s", strerror(errno));
-       return;
+               logit("Setting tty modes failed: %.100s", strerror(errno));
 }
This page took 0.035712 seconds and 4 git commands to generate.