aboutsummaryrefslogtreecommitdiff
path: root/drivers/char
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2012-08-07 21:47:39 +0200
committerBen Hutchings <ben@decadent.org.uk>2012-10-17 03:48:10 +0100
commit49167eecdec7620e15678f7a0ac30c4e8e4b32db (patch)
tree02bba71b2f5dcb9747466d721c6c600f3a1058ef /drivers/char
parent563ce0476bddbd8e9818c3c7088186dd01479ffe (diff)
TTY: ttyprintk, don't touch behind tty->write_buf
commit ee8b593affdf893012e57f4c54a21984d1b0d92e upstream. If a user provides a buffer larger than a tty->write_buf chunk and passes '\r' at the end of the buffer, we touch an out-of-bound memory. Add a check there to prevent this. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Samo Pogacnik <samo_pogacnik@t-2.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/ttyprintk.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/char/ttyprintk.c b/drivers/char/ttyprintk.c
index eedd5474850..59366915eee 100644
--- a/drivers/char/ttyprintk.c
+++ b/drivers/char/ttyprintk.c
@@ -67,7 +67,7 @@ static int tpk_printk(const unsigned char *buf, int count)
tmp[tpk_curr + 1] = '\0';
printk(KERN_INFO "%s%s", tpk_tag, tmp);
tpk_curr = 0;
- if (buf[i + 1] == '\n')
+ if ((i + 1) < count && buf[i + 1] == '\n')
i++;
break;
case '\n':