* [Qemu-devel] [PATCH] console: Avoid dereferencing NULL active_console
@ 2010-09-20 13:11 Stefan Hajnoczi
2010-09-29 8:44 ` [Qemu-devel] " Gerd Hoffmann
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2010-09-20 13:11 UTC (permalink / raw)
To: qemu-devel
Cc: Anthony Liguori, Gerd Hoffmann, Michal Suchanek, Stefan Hajnoczi
The console_select() function does not check that active_console is
non-NULL before dereferencing it. When invoked with qemu -nodefaults 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 <stefanha@linux.vnet.ibm.com>
---
console.c | 6 ++++--
1 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)
if (index >= MAX_CONSOLES)
return;
- active_console->g_width = ds_get_width(active_console->ds);
- active_console->g_height = ds_get_height(active_console->ds);
+ if (active_console) {
+ active_console->g_width = ds_get_width(active_console->ds);
+ active_console->g_height = ds_get_height(active_console->ds);
+ }
s = consoles[index];
if (s) {
DisplayState *ds = s->ds;
--
1.7.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] Re: [PATCH] console: Avoid dereferencing NULL active_console
2010-09-20 13:11 [Qemu-devel] [PATCH] console: Avoid dereferencing NULL active_console Stefan Hajnoczi
@ 2010-09-29 8:44 ` Gerd Hoffmann
2010-09-30 16:55 ` [Qemu-devel] " Stefan Weil
2010-10-03 7:52 ` Blue Swirl
2 siblings, 0 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2010-09-29 8:44 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: Anthony Liguori, qemu-devel, Michal Suchanek
On 09/20/10 15:11, Stefan Hajnoczi wrote:
> The console_select() function does not check that active_console is
> non-NULL before dereferencing it. When invoked with qemu -nodefaults 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().
Looks sane to me, simliar tests exist in other places.
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
cheers,
Gerd
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] console: Avoid dereferencing NULL active_console
2010-09-20 13:11 [Qemu-devel] [PATCH] console: Avoid dereferencing NULL active_console Stefan Hajnoczi
2010-09-29 8:44 ` [Qemu-devel] " Gerd Hoffmann
@ 2010-09-30 16:55 ` Stefan Weil
2010-10-03 7:52 ` Blue Swirl
2 siblings, 0 replies; 4+ messages in thread
From: Stefan Weil @ 2010-09-30 16:55 UTC (permalink / raw)
To: Stefan Hajnoczi
Cc: Anthony Liguori, qemu-devel, Michal Suchanek, Gerd Hoffmann
Am 20.09.2010 15:11, schrieb Stefan Hajnoczi:
> The console_select() function does not check that active_console is
> non-NULL before dereferencing it. When invoked with qemu -nodefaults 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 <stefanha@linux.vnet.ibm.com>
> ---
> console.c | 6 ++++--
> 1 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)
>
> if (index >= MAX_CONSOLES)
> return;
> - active_console->g_width = ds_get_width(active_console->ds);
> - active_console->g_height = ds_get_height(active_console->ds);
> + if (active_console) {
> + active_console->g_width = ds_get_width(active_console->ds);
> + active_console->g_height = ds_get_height(active_console->ds);
> + }
> s = consoles[index];
> if (s) {
> DisplayState *ds = s->ds;
To avoid that still more people fix the same bug,
I'd appreciate shorter commit times for simple patches like this one.
Cheers,
Stefan
Acked-by: Stefan Weil <weil@mail.berlios.de>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] console: Avoid dereferencing NULL active_console
2010-09-20 13:11 [Qemu-devel] [PATCH] console: Avoid dereferencing NULL active_console Stefan Hajnoczi
2010-09-29 8:44 ` [Qemu-devel] " Gerd Hoffmann
2010-09-30 16:55 ` [Qemu-devel] " Stefan Weil
@ 2010-10-03 7:52 ` Blue Swirl
2 siblings, 0 replies; 4+ messages in thread
From: Blue Swirl @ 2010-10-03 7:52 UTC (permalink / raw)
To: Stefan Hajnoczi
Cc: Anthony Liguori, qemu-devel, Michal Suchanek, Gerd Hoffmann
Thanks, applied.
On Mon, Sep 20, 2010 at 1:11 PM, Stefan Hajnoczi
<stefanha@linux.vnet.ibm.com> wrote:
> The console_select() function does not check that active_console is
> non-NULL before dereferencing it. When invoked with qemu -nodefaults 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 <stefanha@linux.vnet.ibm.com>
> ---
> console.c | 6 ++++--
> 1 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)
>
> if (index >= MAX_CONSOLES)
> return;
> - active_console->g_width = ds_get_width(active_console->ds);
> - active_console->g_height = ds_get_height(active_console->ds);
> + if (active_console) {
> + active_console->g_width = ds_get_width(active_console->ds);
> + active_console->g_height = ds_get_height(active_console->ds);
> + }
> s = consoles[index];
> if (s) {
> DisplayState *ds = s->ds;
> --
> 1.7.1
>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-10-03 7:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-20 13:11 [Qemu-devel] [PATCH] console: Avoid dereferencing NULL active_console Stefan Hajnoczi
2010-09-29 8:44 ` [Qemu-devel] " Gerd Hoffmann
2010-09-30 16:55 ` [Qemu-devel] " Stefan Weil
2010-10-03 7:52 ` Blue Swirl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).