From d25cfced9221ae9da24a8040166c13fbe64c3f49 Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Mon, 12 Jun 2006 10:05:55 +0100 Subject: [PATCH] [XEN] Fix read_console_ring() when passed a small buffer. From: Akio Takebe Signed-off-by: Keir Fraser --- xen/drivers/char/console.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index f3a547038e..9e474d94cf 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -230,7 +230,7 @@ long read_console_ring(XEN_GUEST_HANDLE(char) str, u32 *pcount, int clear) sofar = 0; c = conringc; - while ( c != conringp ) + while ( (c != conringp) && (sofar < max) ) { idx = CONRING_IDX_MASK(c); len = conringp - c; @@ -247,7 +247,10 @@ long read_console_ring(XEN_GUEST_HANDLE(char) str, u32 *pcount, int clear) if ( clear ) { spin_lock_irqsave(&console_lock, flags); - conringc = conringp; + if ( (conringp - c) > CONRING_SIZE ) + conringc = conringp - CONRING_SIZE; + else + conringc = c; spin_unlock_irqrestore(&console_lock, flags); } -- 2.30.2