From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IKclW-00029A-H3 for qemu-devel@nongnu.org; Mon, 13 Aug 2007 12:27:38 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IKclV-00028G-Rg for qemu-devel@nongnu.org; Mon, 13 Aug 2007 12:27:38 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IKclV-000284-J6 for qemu-devel@nongnu.org; Mon, 13 Aug 2007 12:27:37 -0400 Received: from neurosis.mit.edu ([18.95.3.133] helo=neurosis.jim.sh) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IKclV-0001CK-B8 for qemu-devel@nongnu.org; Mon, 13 Aug 2007 12:27:37 -0400 Date: Mon, 13 Aug 2007 12:27:31 -0400 From: Jim Paris Message-ID: <20070813162731.GA26350@jim.sh> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: jim@jim.sh Subject: [Qemu-devel] [PATCH] qemu: reset buffer pointers after CR/LF Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: jim@jtan.com If readline_handle_byte() is sent both a CR and LF, and readline_start() is not called after the first CR, then the LF will cause the same command to be executed a second time. Fix this by explicitly resetting the buffer pointers when it is processed. Signed-off-by: Jim Paris --- Index: readline.c =================================================================== RCS file: /sources/qemu/qemu/readline.c,v retrieving revision 1.2 diff -u -r1.2 readline.c --- readline.c 25 Jun 2007 11:36:50 -0000 1.2 +++ readline.c 13 Aug 2007 16:23:29 -0000 @@ -374,6 +374,10 @@ if (!term_is_password) term_hist_add(term_cmd_buf); term_printf("\n"); + term_cmd_buf_index = 0; + term_cmd_buf_size = 0; + term_last_cmd_buf_index = 0; + term_last_cmd_buf_size = 0; /* NOTE: readline_start can be called here */ term_readline_func(term_readline_opaque, term_cmd_buf); break;