Fix el_no_echo bug leaking secrets to screen and history

This patch makes el_no_echo actually work:

- Don't echo to screen
- Don't save to history

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson 2014-06-25 03:05:53 +02:00
parent 7330f21c28
commit 29b7f91165

View File

@ -167,6 +167,9 @@ static void tty_flush(void)
static void tty_put(const char c) static void tty_put(const char c)
{ {
if (el_no_echo)
return;
Screen[ScreenCount] = c; Screen[ScreenCount] = c;
if (++ScreenCount >= ScreenSize - 1) { if (++ScreenCount >= ScreenSize - 1) {
ScreenSize += SCREEN_INC; ScreenSize += SCREEN_INC;
@ -1180,9 +1183,11 @@ char *readline(const char *prompt)
free(Screen); free(Screen);
free(H.Lines[--H.Size]); free(H.Lines[--H.Size]);
/* Always add history, if it's a sane line. */ /* Add to history, unless no-echo mode ... */
if (line != NULL && *line != '\0') if (!el_no_echo) {
hist_add(line); if (line != NULL && *line != '\0')
hist_add(line);
}
if (el_intr_pending > 0) { if (el_intr_pending > 0) {
int s = el_intr_pending; int s = el_intr_pending;