From: Brendan Cully Date: Mon, 14 Jul 2003 12:17:43 +0000 (+0000) Subject: The attached patch prevents mutt from reading the push buffer when X-Git-Tag: pre-type-punning-patch~55 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c4ef62a751b0727a7a5c332a048df84fb1939c09;p=mutt The attached patch prevents mutt from reading the push buffer when asking for passwords. This is a proper fix for bug 1312. I think it's uncontroversial. --- diff --git a/account.c b/account.c index 5a7fe790..3fda792b 100644 --- a/account.c +++ b/account.c @@ -172,7 +172,7 @@ int mutt_account_getpass (ACCOUNT* account) snprintf (prompt, sizeof (prompt), _("Password for %s@%s: "), account->user, account->host); account->pass[0] = '\0'; - if (mutt_get_field (prompt, account->pass, sizeof (account->pass), M_PASS)) + if (mutt_get_password (prompt, account->pass, sizeof (account->pass))) return -1; } diff --git a/curs_lib.c b/curs_lib.c index ba120bd4..5f5247c3 100644 --- a/curs_lib.c +++ b/curs_lib.c @@ -57,12 +57,12 @@ void mutt_refresh (void) refresh (); } -event_t mutt_getch (void) +event_t _mutt_getch (int flags) { int ch; event_t err = {-1, OP_NULL }, ret; - if (UngetCount) + if (!(flags & M_KM_UNBUFFERED) && UngetCount) return (KeyEvent[--UngetCount]); SigInt = 0; diff --git a/enter.c b/enter.c index bd436ba5..b96eadb2 100644 --- a/enter.c +++ b/enter.c @@ -256,7 +256,7 @@ int _mutt_enter_string (char *buf, size_t buflen, int y, int x, } mutt_refresh (); - if ((ch = km_dokey (MENU_EDITOR)) == -1) + if ((ch = _km_dokey (MENU_EDITOR, pass ? M_KM_UNBUFFERED : 0)) == -1) { rv = -1; goto bye; diff --git a/keymap.c b/keymap.c index 6fa4729e..f81af2b5 100644 --- a/keymap.c +++ b/keymap.c @@ -357,7 +357,7 @@ static int retry_generic (int menu, keycode_t *keys, int keyslen, int lastkey) * OP_NULL no function bound to key sequence * -1 error occured while reading input */ -int km_dokey (int menu) +int _km_dokey (int menu, int flags) { event_t tmp; struct keymap_t *map = Keymaps[menu]; @@ -374,7 +374,7 @@ int km_dokey (int menu) if (menu != MENU_EDITOR) timeout ((Timeout > 0 ? Timeout : 60) * 1000); - tmp = mutt_getch(); + tmp = _mutt_getch(flags); if (menu != MENU_EDITOR) timeout (-1); /* restore blocking operation */ diff --git a/keymap.h b/keymap.h index bdbafae6..392910a5 100644 --- a/keymap.h +++ b/keymap.h @@ -27,7 +27,8 @@ typedef short keycode_t; void km_bind (char *, int, int, char *, char *); void km_bindkey (char *, int, int); -int km_dokey (int); +#define km_dokey(menu) _km_dokey(menu, 0) +int _km_dokey (int, int); /* entry in the keymap tree */ struct keymap_t diff --git a/mutt.h b/mutt.h index 8e1f2dd4..d21d107e 100644 --- a/mutt.h +++ b/mutt.h @@ -112,6 +112,9 @@ #define M_TOKEN_COMMENT (1<<5) /* don't reap comments */ #define M_TOKEN_SEMICOLON (1<<6) /* don't treat ; as special */ +/* flags for km_dokey() */ +#define M_KM_UNBUFFERED 1 /* don't read from the key buffer */ + typedef struct { char *data; /* pointer to data */ diff --git a/mutt_curses.h b/mutt_curses.h index b7b1a828..96668327 100644 --- a/mutt_curses.h +++ b/mutt_curses.h @@ -87,7 +87,8 @@ void mutt_curs_set (int); #define CI_is_return(c) ((c) == '\r' || (c) == '\n') #endif -event_t mutt_getch (void); +#define mutt_getch() _mutt_getch(0) +event_t _mutt_getch (int); void mutt_endwin (const char *); void mutt_flushinp (void);