OSDN Git Service

net/ethernet/qlogic/qed: force the string buffer NULL-terminated
authorWang Xiayang <xywang.sjtu@sjtu.edu.cn>
Wed, 31 Jul 2019 08:15:42 +0000 (16:15 +0800)
committerDavid S. Miller <davem@davemloft.net>
Sat, 3 Aug 2019 00:57:18 +0000 (17:57 -0700)
commit3690c8c9a8edff0db077a38783112d8fe12a7dd2
treec8f99e8488c5ebf0032bd458e87dde01ccf5fc4e
parentea443e5e98b5b74e317ef3d26bcaea54931ccdee
net/ethernet/qlogic/qed: force the string buffer NULL-terminated

strncpy() does not ensure NULL-termination when the input string
size equals to the destination buffer size 30.
The output string is passed to qed_int_deassertion_aeu_bit()
which calls DP_INFO() and relies NULL-termination.

Use strlcpy instead. The other conditional branch above strncpy()
needs no fix as snprintf() ensures NULL-termination.

This issue is identified by a Coccinelle script.

Signed-off-by: Wang Xiayang <xywang.sjtu@sjtu.edu.cn>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/qlogic/qed/qed_int.c