From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mail.tricorecenter.de ([217.6.246.34] helo=root.phytec.de) by casper.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1RTWrb-0003id-Ej for barebox@lists.infradead.org; Thu, 24 Nov 2011 10:49:08 +0000 Received: from idefix.phytec.de (idefix.phytec.de [172.16.0.10]) by root.phytec.de (Postfix) with ESMTP id 2D256BF0DC for ; Thu, 24 Nov 2011 11:54:05 +0100 (CET) From: Jan Weitzel Date: Thu, 24 Nov 2011 11:48:54 +0100 Message-Id: <1322131734-30864-1-git-send-email-j.weitzel@phytec.de> In-Reply-To: <4ECE0C16.4040602@pengutronix.de> References: <4ECE0C16.4040602@pengutronix.de> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: barebox-bounces@lists.infradead.org Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH v2] readkey: force return from while true To: barebox@lists.infradead.org If read_key is feeded by STRG + KEY_LEFT you run into the while(1) loop and corrupt memory through esc array. Force return if index gets too high. Signed-off-by: Jan Weitzel --- v2: use ARRAY_SIZE lib/readkey.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/lib/readkey.c b/lib/readkey.c index a42d1cb..1117c30 100644 --- a/lib/readkey.c +++ b/lib/readkey.c @@ -67,6 +67,8 @@ int read_key(void) esc[i] = getc(); if (esc[i++] == '~') break; + if (i == ARRAY_SIZE(esc)) + return -1; } } esc[i] = 0; -- 1.7.0.4 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox