]> git.karo-electronics.de Git - linux-beck.git/commit
tty: nozomi: avoid sprintf buffer overflow
authorArnd Bergmann <arnd@arndb.de>
Tue, 29 Nov 2016 11:51:04 +0000 (12:51 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 29 Nov 2016 19:20:07 +0000 (20:20 +0100)
commit5020ded78348092eac5e9909018f6d53e24eadb6
tree6c13f132c3788411b7a8efc2ea8e24f27dfbfa3c
parentf209fa03fc9d131b3108c2e4936181eabab87416
tty: nozomi: avoid sprintf buffer overflow

Testing with a gcc-7 snapshot produced an internal compiler error
for this file:

drivers/tty/nozomi.c: In function 'receive_flow_control':
drivers/tty/nozomi.c:919:12: internal compiler error: in get_substring_ranges_for_loc, at input.c:1388
 static int receive_flow_control(struct nozomi *dc)

I've reported this at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78569
but also noticed that the code line contains a stack overflow, as it prints
a string into a slightly shorter fixed-length 'tmp' variable.

A lot of the code here is unnecessary and can be expressed in a simpler
way, relying on the fact that removing the 'DEBUG' macro will also get
rid of all pr_debug() calls. This change should not change any of the
output but avoids both the stack overflow and the gcc crash.

The stack overflow will not happen unless a module load parameter is
also set to enable the debug messages.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/nozomi.c