summaryrefslogtreecommitdiff
path: root/ttymodes.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2008-06-08 12:53:20 +1000
committerDarren Tucker <dtucker@zip.com.au>2008-06-08 12:53:20 +1000
commitdd39264e4b4fcd5a9fd4141b1f7b10eff09b3f8c (patch)
tree0430fcc66e198ba19cf1039fe6bc5b488bb65344 /ttymodes.c
parent136e56f68967fd39e8868769f3af316f1cca0559 (diff)
- djm@cvs.openbsd.org 2008/05/19 15:45:07
[sshtty.c ttymodes.c sshpty.h] Fix sending tty modes when stdin is not a tty (bz#1199). Previously we would send the modes corresponding to a zeroed struct termios, whereas we should have been sending an empty list of modes. Based on patch from daniel.ritz AT alcatel.ch; ok dtucker@ markus@
Diffstat (limited to 'ttymodes.c')
-rw-r--r--ttymodes.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/ttymodes.c b/ttymodes.c
index d8e2c553a..d11d00c28 100644
--- a/ttymodes.c
+++ b/ttymodes.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ttymodes.c,v 1.26 2006/08/03 03:34:42 deraadt Exp $ */ 1/* $OpenBSD: ttymodes.c,v 1.27 2008/05/19 15:45:07 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -298,6 +298,10 @@ tty_make_modes(int fd, struct termios *tiop)
298 } 298 }
299 299
300 if (tiop == NULL) { 300 if (tiop == NULL) {
301 if (fd == -1) {
302 debug("tty_make_modes: no fd or tio");
303 goto end;
304 }
301 if (tcgetattr(fd, &tio) == -1) { 305 if (tcgetattr(fd, &tio) == -1) {
302 logit("tcgetattr: %.100s", strerror(errno)); 306 logit("tcgetattr: %.100s", strerror(errno));
303 goto end; 307 goto end;
@@ -317,12 +321,10 @@ tty_make_modes(int fd, struct termios *tiop)
317 321
318 /* Store values of mode flags. */ 322 /* Store values of mode flags. */
319#define TTYCHAR(NAME, OP) \ 323#define TTYCHAR(NAME, OP) \
320 debug3("tty_make_modes: %d %d", OP, tio.c_cc[NAME]); \
321 buffer_put_char(&buf, OP); \ 324 buffer_put_char(&buf, OP); \
322 put_arg(&buf, special_char_encode(tio.c_cc[NAME])); 325 put_arg(&buf, special_char_encode(tio.c_cc[NAME]));
323 326
324#define TTYMODE(NAME, FIELD, OP) \ 327#define TTYMODE(NAME, FIELD, OP) \
325 debug3("tty_make_modes: %d %d", OP, ((tio.FIELD & NAME) != 0)); \
326 buffer_put_char(&buf, OP); \ 328 buffer_put_char(&buf, OP); \
327 put_arg(&buf, ((tio.FIELD & NAME) != 0)); 329 put_arg(&buf, ((tio.FIELD & NAME) != 0));
328 330
@@ -410,7 +412,6 @@ tty_parse_modes(int fd, int *n_bytes_ptr)
410 case OP: \ 412 case OP: \
411 n_bytes += arg_size; \ 413 n_bytes += arg_size; \
412 tio.c_cc[NAME] = special_char_decode(get_arg()); \ 414 tio.c_cc[NAME] = special_char_decode(get_arg()); \
413 debug3("tty_parse_modes: %d %d", OP, tio.c_cc[NAME]); \
414 break; 415 break;
415#define TTYMODE(NAME, FIELD, OP) \ 416#define TTYMODE(NAME, FIELD, OP) \
416 case OP: \ 417 case OP: \
@@ -419,7 +420,6 @@ tty_parse_modes(int fd, int *n_bytes_ptr)
419 tio.FIELD |= NAME; \ 420 tio.FIELD |= NAME; \
420 else \ 421 else \
421 tio.FIELD &= ~NAME; \ 422 tio.FIELD &= ~NAME; \
422 debug3("tty_parse_modes: %d %d", OP, arg); \
423 break; 423 break;
424 424
425#include "ttymodes.h" 425#include "ttymodes.h"