From patchwork Thu Aug 11 14:23:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 9275353 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 424396022E for ; Thu, 11 Aug 2016 14:25:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3048C286BF for ; Thu, 11 Aug 2016 14:25:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 217EF286C1; Thu, 11 Aug 2016 14:25:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9E834286BF for ; Thu, 11 Aug 2016 14:25:11 +0000 (UTC) Received: from localhost ([::1]:48844 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXqv0-0002PI-Qq for patchwork-qemu-devel@patchwork.kernel.org; Thu, 11 Aug 2016 10:25:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41749) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXqtV-0001X0-QQ for qemu-devel@nongnu.org; Thu, 11 Aug 2016 10:23:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bXqtU-0007zS-US for qemu-devel@nongnu.org; Thu, 11 Aug 2016 10:23:37 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:58595) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXqtU-0007wH-Mm for qemu-devel@nongnu.org; Thu, 11 Aug 2016 10:23:36 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.84_2) (envelope-from ) id 1bXqtM-0002fI-FG; Thu, 11 Aug 2016 15:23:28 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 11 Aug 2016 15:23:26 +0100 Message-Id: <1470925407-23850-2-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1470925407-23850-1-git-send-email-peter.maydell@linaro.org> References: <1470925407-23850-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PATCH 1/2] ui/curses.c: Ensure we don't read off the end of curses2qemu array X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann , patches@linaro.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Coverity spots that there is no bounds check before we access the curses2qemu[] array. Add one, bringing this code path into line with the one that looks up entries in curses2keysym[]. In theory getch() shouldn't return out of range keycodes, but it's better not to assume this. Signed-off-by: Peter Maydell --- ui/curses.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ui/curses.c b/ui/curses.c index b475589..f1f886c 100644 --- a/ui/curses.c +++ b/ui/curses.c @@ -317,7 +317,10 @@ static void curses_refresh(DisplayChangeListener *dcl) qemu_input_event_send_key_delay(0); } } else { - keysym = curses2qemu[chr]; + keysym = -1; + if (chr < CURSES_KEYS) { + keysym = curses2qemu[chr]; + } if (keysym == -1) keysym = chr;