From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=59911 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P2JMt-0003dS-Be for qemu-devel@nongnu.org; Sun, 03 Oct 2010 03:52:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P2JMr-0001AR-HX for qemu-devel@nongnu.org; Sun, 03 Oct 2010 03:52:23 -0400 Received: from mail-qy0-f180.google.com ([209.85.216.180]:33697) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P2JMr-0001AN-El for qemu-devel@nongnu.org; Sun, 03 Oct 2010 03:52:21 -0400 Received: by qyk5 with SMTP id 5so6174717qyk.4 for ; Sun, 03 Oct 2010 00:52:21 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <1284988279-8900-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1284988279-8900-1-git-send-email-stefanha@linux.vnet.ibm.com> From: Blue Swirl Date: Sun, 3 Oct 2010 07:52:00 +0000 Message-ID: Subject: Re: [Qemu-devel] [PATCH] console: Avoid dereferencing NULL active_console Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Anthony Liguori , qemu-devel@nongnu.org, Michal Suchanek , Gerd Hoffmann Thanks, applied. On Mon, Sep 20, 2010 at 1:11 PM, Stefan Hajnoczi wrote: > The console_select() function does not check that active_console is > non-NULL before dereferencing it. =C2=A0When invoked with qemu -nodefault= s it > is possible to hit this case. > > This patch checks that active_console is non-NULL before stashing away > the old console dimensions in console_select(). > > Signed-off-by: Stefan Hajnoczi > --- > =C2=A0console.c | =C2=A0 =C2=A06 ++++-- > =C2=A01 files changed, 4 insertions(+), 2 deletions(-) > > diff --git a/console.c b/console.c > index 698bc10..c1728b1 100644 > --- a/console.c > +++ b/console.c > @@ -1060,8 +1060,10 @@ void console_select(unsigned int index) > > =C2=A0 =C2=A0 if (index >=3D MAX_CONSOLES) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 return; > - =C2=A0 =C2=A0active_console->g_width =3D ds_get_width(active_console->d= s); > - =C2=A0 =C2=A0active_console->g_height =3D ds_get_height(active_console-= >ds); > + =C2=A0 =C2=A0if (active_console) { > + =C2=A0 =C2=A0 =C2=A0 =C2=A0active_console->g_width =3D ds_get_width(act= ive_console->ds); > + =C2=A0 =C2=A0 =C2=A0 =C2=A0active_console->g_height =3D ds_get_height(a= ctive_console->ds); > + =C2=A0 =C2=A0} > =C2=A0 =C2=A0 s =3D consoles[index]; > =C2=A0 =C2=A0 if (s) { > =C2=A0 =C2=A0 =C2=A0 =C2=A0 DisplayState *ds =3D s->ds; > -- > 1.7.1 > > >