summaryrefslogtreecommitdiff
path: root/libbb/lineedit.c
diff options
context:
space:
mode:
authorDenis Vlasenko2008-08-20 00:46:32 +0000
committerDenis Vlasenko2008-08-20 00:46:32 +0000
commitf31c3b677d588795b18f02a6b8de22057bfab4af (patch)
tree5aa9bb30f7b73673b2c44a07bd6bcfb333a3b280 /libbb/lineedit.c
parent4301616b27afa808eeb8ea619dd7f3f9fa540462 (diff)
downloadbusybox-f31c3b677d588795b18f02a6b8de22057bfab4af.zip
busybox-f31c3b677d588795b18f02a6b8de22057bfab4af.tar.gz
linedit: fix use-after-free
Diffstat (limited to 'libbb/lineedit.c')
-rw-r--r--libbb/lineedit.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index 3e16f64..a68e5a3 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -1357,6 +1357,7 @@ static void win_changed(int nsig)
*/
int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, line_input_t *st)
{
+ int len;
#if ENABLE_FEATURE_TAB_COMPLETION
smallint lastWasTab = FALSE;
#endif
@@ -1376,7 +1377,6 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li
|| !(initial_settings.c_lflag & ECHO)
) {
/* Happens when e.g. stty -echo was run before */
- int len;
parse_and_put_prompt(prompt);
fflush(stdout);
if (fgets(command, maxsize, stdin) == NULL)
@@ -1843,9 +1843,10 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li
signal(SIGWINCH, previous_SIGWINCH_handler);
fflush(stdout);
+ len = command_len;
DEINIT_S();
- return command_len;
+ return len; /* can't return command_len, DEINIT_S() destroys it */
}
line_input_t* FAST_FUNC new_line_input_t(int flags)