]> git.baikalelectronics.ru Git - kernel.git/commit
scsi: fusion: fix string overflow warning
authorArnd Bergmann <arnd@arndb.de>
Mon, 17 Jul 2017 12:00:00 +0000 (14:00 +0200)
committerMartin K. Petersen <martin.petersen@oracle.com>
Mon, 7 Aug 2017 18:04:02 +0000 (14:04 -0400)
commit7ff0cd8dac5f6b56317e12efbcdf4babf5e2a26d
tree079446ef98073b111c8901603177fe8b7691c9d0
parent1b5e24850a6d146b069dd9461b0b9649a95730de
scsi: fusion: fix string overflow warning

gcc points out a theorerical string overflow:

drivers/message/fusion/mptbase.c: In function 'mpt_detach':
drivers/message/fusion/mptbase.c:2103:17: error: '%s' directive writing up to 31 bytes into a region of size 28 [-Werror=format-overflow=]
sprintf(pname, MPT_PROCFS_MPTBASEDIR "/%s/summary", ioc->name);
               ^~~~~
drivers/message/fusion/mptbase.c:2103:2: note: 'sprintf' output between 13 and 44 bytes into a destination of size 32

We can simply double the size of the local buffer here to be on the
safe side, and using snprintf() instead of sprintf() protects us
if ioc->name was not terminated properly.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/message/fusion/mptbase.c