]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
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)
committerPaul Gortmaker <paul.gortmaker@windriver.com>
Mon, 10 Feb 2014 21:11:25 +0000 (16:11 -0500)
commit393762b54f9ea3bdb0a4392da85063c6b7ab79fd
treefd3d6c94a27144b41460cbbd410a94d0de4272ae
parent93925c373315e778707417d2c696326e163da83b
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>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
fs/sysfs/dir.c