diff options
author | Eygene Ryabinkin <rea-fbsd@codelabs.ru> | 2009-01-05 20:48:45 +0200 |
---|---|---|
committer | Jouni Malinen <j@w1.fi> | 2009-01-05 20:48:45 +0200 |
commit | 413653e839dcd9f51e9a900943acb135eec79f20 (patch) | |
tree | 6495736dab2a62bd2de5fac01b4c3ca9ef889938 /wpa_supplicant | |
parent | 7ee6258f7c1fd5a92fa1f60ad5605640aac28c45 (diff) | |
download | external_wpa_supplicant_8_ti-413653e839dcd9f51e9a900943acb135eec79f20.zip external_wpa_supplicant_8_ti-413653e839dcd9f51e9a900943acb135eec79f20.tar.gz external_wpa_supplicant_8_ti-413653e839dcd9f51e9a900943acb135eec79f20.tar.bz2 |
wpa_cli: fix readline history cleaning
First of all, the history had not been written to the disk, since almost
all commands were cleaned up due to the error in the history cleaning:
the return value of the last os_strncasecmp() call was not compared to
zero, but was rather used as is. So the condition was almost always
true and most commands were removed from the history.
The second problem was that the evaluation of the potentially sensitive
commands was started at the entry number 1, instead of very first entry.
Diffstat (limited to 'wpa_supplicant')
-rw-r--r-- | wpa_supplicant/wpa_cli.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c index bd1a5a6..e531001 100644 --- a/wpa_supplicant/wpa_cli.c +++ b/wpa_supplicant/wpa_cli.c @@ -1519,24 +1519,22 @@ static void wpa_cli_interactive(void) * passwords. */ HIST_ENTRY *h; history_set_pos(0); - h = next_history(); - while (h) { + while ((h = current_history())) { char *p = h->line; while (*p == ' ' || *p == '\t') p++; if (os_strncasecmp(p, "pa", 2) == 0 || os_strncasecmp(p, "o", 1) == 0 || - os_strncasecmp(p, "n", 1)) { + os_strncasecmp(p, "n", 1) == 0) { h = remove_history(where_history()); if (h) { os_free(h->line); os_free(h->data); os_free(h); - } - h = current_history(); - } else { - h = next_history(); - } + } else + next_history(); + } else + next_history(); } write_history(hfile); os_free(hfile); |