summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2008-05-19 15:45:08 +0000
committerDamien Miller <djm@cvs.openbsd.org>2008-05-19 15:45:08 +0000
commit598ef7150f30391faa91b0547abd92cfe1f53987 (patch)
treebdca53ff2b27164841bfdb80501be6f2a85c3396
parentfa807a50f99bead557768de9606d5a2fafb88292 (diff)
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@
-rw-r--r--usr.bin/ssh/sshpty.h4
-rw-r--r--usr.bin/ssh/sshtty.c6
-rw-r--r--usr.bin/ssh/ttymodes.c10
3 files changed, 10 insertions, 10 deletions
diff --git a/usr.bin/ssh/sshpty.h b/usr.bin/ssh/sshpty.h
index 7fac622d9be..ac900358462 100644
--- a/usr.bin/ssh/sshpty.h
+++ b/usr.bin/ssh/sshpty.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sshpty.h,v 1.10 2006/08/03 03:34:42 deraadt Exp $ */
+/* $OpenBSD: sshpty.h,v 1.11 2008/05/19 15:45:07 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -16,7 +16,7 @@
#include <termios.h>
-struct termios get_saved_tio(void);
+struct termios *get_saved_tio(void);
void leave_raw_mode(void);
void enter_raw_mode(void);
diff --git a/usr.bin/ssh/sshtty.c b/usr.bin/ssh/sshtty.c
index 5245817f44f..9df9aa219e4 100644
--- a/usr.bin/ssh/sshtty.c
+++ b/usr.bin/ssh/sshtty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sshtty.c,v 1.12 2006/08/03 03:34:42 deraadt Exp $ */
+/* $OpenBSD: sshtty.c,v 1.13 2008/05/19 15:45:07 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -45,10 +45,10 @@
static struct termios _saved_tio;
static int _in_raw_mode = 0;
-struct termios
+struct termios *
get_saved_tio(void)
{
- return _saved_tio;
+ return _in_raw_mode ? &_saved_tio : NULL;
}
void
diff --git a/usr.bin/ssh/ttymodes.c b/usr.bin/ssh/ttymodes.c
index e7096816d95..3dd43cb9da3 100644
--- a/usr.bin/ssh/ttymodes.c
+++ b/usr.bin/ssh/ttymodes.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ttymodes.c,v 1.26 2006/08/03 03:34:42 deraadt Exp $ */
+/* $OpenBSD: ttymodes.c,v 1.27 2008/05/19 15:45:07 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -270,6 +270,10 @@ tty_make_modes(int fd, struct termios *tiop)
}
if (tiop == NULL) {
+ if (fd == -1) {
+ debug("tty_make_modes: no fd or tio");
+ goto end;
+ }
if (tcgetattr(fd, &tio) == -1) {
logit("tcgetattr: %.100s", strerror(errno));
goto end;
@@ -289,12 +293,10 @@ tty_make_modes(int fd, struct termios *tiop)
/* Store values of mode flags. */
#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]);
#define TTYMODE(NAME, FIELD, OP) \
- debug3("tty_make_modes: %d %d", OP, ((tio.FIELD & NAME) != 0)); \
buffer_put_char(&buf, OP); \
put_arg(&buf, ((tio.FIELD & NAME) != 0));
@@ -382,7 +384,6 @@ tty_parse_modes(int fd, int *n_bytes_ptr)
case OP: \
n_bytes += arg_size; \
tio.c_cc[NAME] = get_arg(); \
- debug3("tty_parse_modes: %d %d", OP, tio.c_cc[NAME]); \
break;
#define TTYMODE(NAME, FIELD, OP) \
case OP: \
@@ -391,7 +392,6 @@ tty_parse_modes(int fd, int *n_bytes_ptr)
tio.FIELD |= NAME; \
else \
tio.FIELD &= ~NAME; \
- debug3("tty_parse_modes: %d %d", OP, arg); \
break;
#include "ttymodes.h"