From ed66791aba119e8f5f39d4749ad31b6b885b1d6f Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Mon, 9 Nov 2009 15:38:36 +0000 Subject: [PATCH] * fhandler_console.cc (fhandler_console::read): Restrict generating META key sequences to singlebyte input chars. --- winsup/cygwin/ChangeLog | 5 +++++ winsup/cygwin/fhandler_console.cc | 27 ++++++++++++++++----------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 02e616606..3e89d7687 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2009-11-09 Corinna Vinschen + + * fhandler_console.cc (fhandler_console::read): Restrict generating + META key sequences to singlebyte input chars. + 2009-11-08 Corinna Vinschen * fhandler_disk_file.cc (fhandler_base::fstat_helper): Drop all "other" diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc index 632ec1dcb..8bfccde0b 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -379,18 +379,23 @@ fhandler_console::read (void *pv, size_t& buflen) else toadd = tmp + 1; } - else if (dev_state->metabit) + else if (nread == 1) { - tmp[1] |= 0x80; - toadd = tmp + 1; - } - else - { - tmp[0] = '\033'; - tmp[1] = cyg_tolower (tmp[1]); - toadd = tmp; - nread++; - dev_state->nModifiers &= ~4; + /* META handling is restricted to singlebyte (ASCII) + character values. */ + if (dev_state->metabit) + { + tmp[1] |= 0x80; + toadd = tmp + 1; + } + else + { + tmp[0] = '\033'; + tmp[1] = cyg_tolower (tmp[1]); + toadd = tmp; + nread++; + dev_state->nModifiers &= ~4; + } } } #undef ich