diff options
author | Denis Vlasenko | 2007-08-03 14:17:21 +0000 |
---|---|---|
committer | Denis Vlasenko | 2007-08-03 14:17:21 +0000 |
commit | 46340e398e93898ce097b06f5e26c86e33fd651a (patch) | |
tree | 45a657af806c6cb6eed024a17dd4a5444c1c25ea /miscutils | |
parent | 0e2c9fb4e09fb0c5a47ddc74b0ba53238570599e (diff) | |
download | busybox-46340e398e93898ce097b06f5e26c86e33fd651a.zip busybox-46340e398e93898ce097b06f5e26c86e33fd651a.tar.gz |
less: add a bit more robustness in keyboard reading code
Diffstat (limited to 'miscutils')
-rw-r--r-- | miscutils/less.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/miscutils/less.c b/miscutils/less.c index 9b2c43b..a6649c5 100644 --- a/miscutils/less.c +++ b/miscutils/less.c @@ -699,10 +699,11 @@ static int less_getch(void) char input[16]; unsigned i; again: + memset(input, 0, sizeof(input)); getch_nowait(input, sizeof(input)); + /* Detect escape sequences (i.e. arrow keys) and handle * them accordingly */ - if (input[0] == '\033' && input[1] == '[') { set_tty_cooked(); i = input[2] - REAL_KEY_UP; @@ -740,6 +741,7 @@ static char* less_gets(int sz) * but it is needed. Is it because of stdio? */ tcsetattr(kbd_fd, TCSANOW, &term_less); + c = '\0'; read(kbd_fd, &c, 1); if (c == 0x0d) return result; |