diff options
author | Jiri Slaby <jslaby@suse.cz> | 2012-08-07 15:47:39 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-08-10 16:29:57 -0400 |
commit | ee8b593affdf893012e57f4c54a21984d1b0d92e (patch) | |
tree | f1c00109d602344142a66ecfa2bca504ce2387bd /drivers/char | |
parent | f06fb543c1d0cbd721250b72ee1244178a38aa9d (diff) |
TTY: ttyprintk, don't touch behind tty->write_buf
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: stable@vger.kernel.org (everything maintained past v2.6.37)
Cc: Samo Pogacnik <samo_pogacnik@t-2.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/ttyprintk.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/char/ttyprintk.c b/drivers/char/ttyprintk.c index 9b1e5e0cdc6..08755c52fc5 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) | |||
67 | tmp[tpk_curr + 1] = '\0'; | 67 | tmp[tpk_curr + 1] = '\0'; |
68 | printk(KERN_INFO "%s%s", tpk_tag, tmp); | 68 | printk(KERN_INFO "%s%s", tpk_tag, tmp); |
69 | tpk_curr = 0; | 69 | tpk_curr = 0; |
70 | if (buf[i + 1] == '\n') | 70 | if ((i + 1) < count && buf[i + 1] == '\n') |
71 | i++; | 71 | i++; |
72 | break; | 72 | break; |
73 | case '\n': | 73 | case '\n': |