From patchwork Tue Sep 13 07:06:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 76039 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp1219885qgf; Tue, 13 Sep 2016 00:09:10 -0700 (PDT) X-Received: by 10.55.31.76 with SMTP id f73mr23149517qkf.260.1473750548894; Tue, 13 Sep 2016 00:09:08 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [208.118.235.17]) by mx.google.com with ESMTPS id m201si8039405qke.257.2016.09.13.00.09.08 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 13 Sep 2016 00:09:08 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:46898 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjhq8-0003Fd-3W for patch@linaro.org; Tue, 13 Sep 2016 03:09:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44434) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjhoA-0002KY-9h for qemu-devel@nongnu.org; Tue, 13 Sep 2016 03:07:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bjho4-0003rJ-FN for qemu-devel@nongnu.org; Tue, 13 Sep 2016 03:07:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54996) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjho4-0003r6-9C for qemu-devel@nongnu.org; Tue, 13 Sep 2016 03:07:00 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EC466C04B317; Tue, 13 Sep 2016 07:06:59 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-48.ams2.redhat.com [10.36.116.48]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u8D76xoi013341; Tue, 13 Sep 2016 03:06:59 -0400 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 3FF03808D2; Tue, 13 Sep 2016 09:06:58 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 13 Sep 2016 09:06:51 +0200 Message-Id: <1473750414-16525-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1473750414-16525-1-git-send-email-kraxel@redhat.com> References: <1473750414-16525-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 13 Sep 2016 07:06:59 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/4] 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: Peter Maydell , Gerd Hoffmann Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell 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 Message-id: 1470925407-23850-2-git-send-email-peter.maydell@linaro.org Signed-off-by: Gerd Hoffmann --- ui/curses.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) -- 1.8.3.1 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;