svn commit: trunk/busybox/libbb

vda at busybox.net vda at busybox.net
Wed Aug 20 00:46:32 UTC 2008


Author: vda
Date: 2008-08-19 17:46:32 -0700 (Tue, 19 Aug 2008)
New Revision: 23113

Log:
linedit: fix use-after-free



Modified:
   trunk/busybox/libbb/lineedit.c


Changeset:
Modified: trunk/busybox/libbb/lineedit.c
===================================================================
--- trunk/busybox/libbb/lineedit.c	2008-08-20 00:15:42 UTC (rev 23112)
+++ trunk/busybox/libbb/lineedit.c	2008-08-20 00:46:32 UTC (rev 23113)
@@ -1357,6 +1357,7 @@
  */
 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 @@
 	 || !(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 @@
 	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)




More information about the busybox-cvs mailing list