All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roel Kluin <roel.kluin@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: [PATCH] hvc_console: prevent wrapping in hvc_console_print()
Date: Tue, 17 Mar 2009 13:19:55 +0100	[thread overview]
Message-ID: <49BF956B.9030109@gmail.com> (raw)

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@gmail.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);

             reply	other threads:[~2009-03-17 12:20 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-17 12:19 Roel Kluin [this message]
2009-03-30 20:35 ` [PATCH] hvc_console: prevent wrapping in hvc_console_print() Andrew Morton
2009-03-30 20:35   ` Andrew Morton
2009-03-30 20:55   ` Josh Boyer
2009-03-30 20:55     ` Josh Boyer
2009-03-30 21:18     ` Andrew Morton
2009-03-30 21:18       ` Andrew Morton
2009-03-31 13:29       ` [PATCH] Add hvc_console to MAINTAINERS Josh Boyer
2009-03-31 21:10         ` Joe Perches
2009-03-31 21:10           ` Joe Perches
2009-03-31 21:22           ` Andrew Morton
2009-03-31 21:22             ` Andrew Morton
2009-03-31 21:40             ` Joe Perches
2009-03-31 21:40               ` Joe Perches
2009-03-31 23:52               ` Josh Boyer
2009-03-31 23:52                 ` Josh Boyer
2009-03-31 23:44         ` Michael Ellerman
2009-03-31 23:44           ` Michael Ellerman
2009-03-31 23:50           ` Josh Boyer
2009-03-31 23:50             ` Josh Boyer
2009-04-01  0:04             ` Michael Ellerman
2009-04-01  0:04               ` Michael Ellerman
2009-04-01  0:20               ` Michael Ellerman
2009-04-01  0:33                 ` Josh Boyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49BF956B.9030109@gmail.com \
    --to=roel.kluin@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.