diff options
author | Ron Yorston <rmy@pobox.com> | 2017-12-09 09:04:58 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2017-12-09 09:04:58 +0000 |
commit | bcf14b82e442e797fdd370afc80a82ef295ac1b0 (patch) | |
tree | 133c2b3df5445c508953fee17576ed932af07c7a /libbb/lineedit.c | |
parent | 65e9c0ad92a316e36efbc584b72b96a7eb8fa9db (diff) | |
parent | a07fead8235c479f428dd5265e4f3539abb9c3fe (diff) | |
download | busybox-w32-bcf14b82e442e797fdd370afc80a82ef295ac1b0.tar.gz busybox-w32-bcf14b82e442e797fdd370afc80a82ef295ac1b0.tar.bz2 busybox-w32-bcf14b82e442e797fdd370afc80a82ef295ac1b0.zip |
Merge branch 'busybox' into merge
Diffstat (limited to 'libbb/lineedit.c')
-rw-r--r-- | libbb/lineedit.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index c0edb7399..3df67abb1 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c | |||
@@ -687,6 +687,18 @@ static void free_tab_completion_data(void) | |||
687 | 687 | ||
688 | static void add_match(char *matched) | 688 | static void add_match(char *matched) |
689 | { | 689 | { |
690 | unsigned char *p = (unsigned char*)matched; | ||
691 | while (*p) { | ||
692 | /* ESC attack fix: drop any string with control chars */ | ||
693 | if (*p < ' ' | ||
694 | || (!ENABLE_UNICODE_SUPPORT && *p >= 0x7f) | ||
695 | || (ENABLE_UNICODE_SUPPORT && *p == 0x7f) | ||
696 | ) { | ||
697 | free(matched); | ||
698 | return; | ||
699 | } | ||
700 | p++; | ||
701 | } | ||
690 | matches = xrealloc_vector(matches, 4, num_matches); | 702 | matches = xrealloc_vector(matches, 4, num_matches); |
691 | matches[num_matches] = matched; | 703 | matches[num_matches] = matched; |
692 | num_matches++; | 704 | num_matches++; |
@@ -2457,6 +2469,8 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman | |||
2457 | bb_error_msg("cur_history:%d cnt_history:%d", state->cur_history, state->cnt_history); | 2469 | bb_error_msg("cur_history:%d cnt_history:%d", state->cur_history, state->cnt_history); |
2458 | #endif | 2470 | #endif |
2459 | 2471 | ||
2472 | /* Get width (before printing prompt) */ | ||
2473 | cmdedit_termw = get_terminal_width(STDIN_FILENO); | ||
2460 | /* Print out the command prompt, optionally ask where cursor is */ | 2474 | /* Print out the command prompt, optionally ask where cursor is */ |
2461 | parse_and_put_prompt(prompt); | 2475 | parse_and_put_prompt(prompt); |
2462 | ask_terminal(); | 2476 | ask_terminal(); |
@@ -2466,8 +2480,6 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman | |||
2466 | S.SIGWINCH_handler.sa_flags = SA_RESTART; | 2480 | S.SIGWINCH_handler.sa_flags = SA_RESTART; |
2467 | sigaction(SIGWINCH, &S.SIGWINCH_handler, &S.SIGWINCH_handler); | 2481 | sigaction(SIGWINCH, &S.SIGWINCH_handler, &S.SIGWINCH_handler); |
2468 | 2482 | ||
2469 | cmdedit_termw = get_terminal_width(STDIN_FILENO); | ||
2470 | |||
2471 | read_key_buffer[0] = 0; | 2483 | read_key_buffer[0] = 0; |
2472 | while (1) { | 2484 | while (1) { |
2473 | /* | 2485 | /* |