[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <49BF956B.9030109@gmail.com>
Date: Tue, 17 Mar 2009 13:19:55 +0100
From: Roel Kluin <roel.kluin@...il.com>
To: Andrew Morton <akpm@...ux-foundation.org>
CC: lkml <linux-kernel@...r.kernel.org>
Subject: [PATCH] hvc_console: prevent wrapping in hvc_console_print()
This was found by code analysis, is it needed?
------------------------------>8-------------8<---------------------------------
If we subtract too much on unsigned i it wraps.
Signed-off-by: Roel Kluin <roel.kluin@...il.com>
---
diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c
index 94e7e3c..d06313c 100644
--- a/drivers/char/hvc_console.c
+++ b/drivers/char/hvc_console.c
@@ -161,10 +161,10 @@ static void hvc_console_print(struct console *co, const char *b,
}
} else {
r = cons_ops[index]->put_chars(vtermnos[index], c, i);
- if (r <= 0) {
+ if (r <= 0 || r > i) {
/* throw away chars on error */
i = 0;
- } else if (r > 0) {
+ } else {
i -= r;
if (i > 0)
memmove(c, c+r, i);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists