]> www.infradead.org Git - users/jedix/linux-maple.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)
committerGuangyu Sun <guangyu.sun@oracle.com>
Tue, 6 Nov 2012 00:33:22 +0000 (16:33 -0800)
commitec8d74ac36be894236ef682228dda613bfcd10ac
tree13362349b93051c9920619058d8db9841658d40f
parent938cc792b1748670580a028d9562ae62e6f77183
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: Guangyu Sun <guangyu.sun@oracle.com>
fs/sysfs/dir.c