sysfs: sysfs_pathname/sysfs_add_one: Use strlcat() instead of strcat()
authorGeert Uytterhoeven <geert@linux-m68k.org>
Sat, 29 Sep 2012 20:23:19 +0000 (22:23 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 31 Oct 2012 17:02:57 +0000 (10:02 -0700)
commitfa3b39b05f40bf7273bcd6c152f0b59005b83480
tree8e8bda4735ede5b3c98947295545972f8e63695e
parent325c6bf91fd3c2e4fea473e9ca4eb30666dadb52
sysfs: sysfs_pathname/sysfs_add_one: Use strlcat() instead of strcat()

commit 66081a72517a131430dcf986775f3268aafcb546 upstream.

The warning check for duplicate sysfs entries can cause a buffer overflow
when printing the warning, as strcat() doesn't check buffer sizes.
Use strlcat() instead.

Since strlcat() doesn't return a pointer to the passed buffer, unlike
strcat(), I had to convert the nested concatenation in sysfs_add_one() to
an admittedly more obscure comma operator construct, to avoid emitting code
for the concatenation if CONFIG_BUG is disabled.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/sysfs/dir.c