]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
TTY: ttyprintk, don't touch behind tty->write_buf
authorJiri Slaby <jslaby@suse.cz>
Tue, 7 Aug 2012 19:47:39 +0000 (21:47 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 7 Oct 2012 15:27:25 +0000 (08:27 -0700)
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>
drivers/char/ttyprintk.c

index a1f68af4ccf476b5e58dd3942c08337e55303d81..acce1a7aac7585521f12ebf8fb8b275883b7d3ba 100644 (file)
@@ -66,7 +66,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':