Skip to content
Commit 0159a930 authored by Dan Carpenter's avatar Dan Carpenter Committed by Marc Kleine-Budde
Browse files

can: slcan: use scnprintf() as a hardening measure



The snprintf() function returns the number of bytes which *would* have
been copied if there were no space. So, since this code does not check
the return value, there if the buffer was not large enough then there
would be a buffer overflow two lines later when it does:

	actual = sl->tty->ops->write(sl->tty, sl->xbuff, n);

Use scnprintf() instead because that returns the number of bytes which
were actually copied.

Fixes: 52f9ac85 ("can: slcan: allow to send commands to the adapter")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/all/YsVA9KoY/ZSvNGYk@kili


Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent e22c8879
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment