diff options
author | 2013-03-26 14:14:08 +0000 | |
---|---|---|
committer | 2013-03-26 14:14:08 +0000 | |
commit | d9aede6b32241a9e23394a0d2904be399ac4d0d7 (patch) | |
tree | 8a03ba32716c792155da4cae93cfa1da72bca70a /usr.bin/tmux/tty-keys.c | |
parent | Include inttypes.h to get PRIx64; ok gilles@ (diff) | |
download | wireguard-openbsd-d9aede6b32241a9e23394a0d2904be399ac4d0d7.tar.xz wireguard-openbsd-d9aede6b32241a9e23394a0d2904be399ac4d0d7.zip |
Only accept partial keys if the timer has not expired, fixes infinite
loop when Escape is pressed the wrong number of times.
Diffstat (limited to 'usr.bin/tmux/tty-keys.c')
-rw-r--r-- | usr.bin/tmux/tty-keys.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/usr.bin/tmux/tty-keys.c b/usr.bin/tmux/tty-keys.c index c31402d7d43..bbd79bed376 100644 --- a/usr.bin/tmux/tty-keys.c +++ b/usr.bin/tmux/tty-keys.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty-keys.c,v 1.58 2013/03/25 11:44:16 nicm Exp $ */ +/* $OpenBSD: tty-keys.c,v 1.59 2013/03/26 14:14:08 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -448,7 +448,7 @@ tty_keys_next(struct tty *tty) const char *buf; size_t len, size; cc_t bspace; - int key, delay; + int key, delay, expired = 0; /* Get key buffer. */ buf = EVBUFFER_DATA(tty->event->input); @@ -508,7 +508,7 @@ first_key: } tk = tty_keys_find(tty, buf + 1, len - 1, &size); - if (tk != NULL) { + if (tk != NULL && (!expired || tk->next == NULL)) { size++; /* include escape */ if (tk->next != NULL) goto partial_key; @@ -540,8 +540,10 @@ partial_key: /* If timer is going, check for expiration. */ if (tty->flags & TTY_TIMER) { if (evtimer_initialized(&tty->key_timer) && - !evtimer_pending(&tty->key_timer, NULL)) + !evtimer_pending(&tty->key_timer, NULL)) { + expired = 1; goto first_key; + } return (0); } |