mirror_ubuntu-kernels/drivers/net/ethernet/hisilicon
Hao Chen 5e3d20617b net: hns3: fix strscpy causing content truncation issue
hns3_dbg_fill_content()/hclge_dbg_fill_content() is aim to integrate some
items to a string for content, and we add '\n' and '\0' in the last
two bytes of content.

strscpy() will add '\0' in the last byte of destination buffer(one of
items), it result in finishing content print ahead of schedule and some
dump content truncation.

One Error log shows as below:
cat mac_list/uc
UC MAC_LIST:

Expected:
UC MAC_LIST:
FUNC_ID  MAC_ADDR            STATE
pf       00:2b:19:05:03:00   ACTIVE

The destination buffer is length-bounded and not required to be
NUL-terminated, so just change strscpy() to memcpy() to fix it.

Fixes: 1cf3d5567f ("net: hns3: fix strncpy() not using dest-buf length as length issue")
Signed-off-by: Hao Chen <chenhao418@huawei.com>
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
Link: https://lore.kernel.org/r/20230809020902.1941471-1-shaojijie@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2023-08-10 11:47:56 -07:00
..
hns driver core: class: remove module * from class_create() 2023-03-17 15:16:33 +01:00
hns3 net: hns3: fix strscpy causing content truncation issue 2023-08-10 11:47:56 -07:00
hip04_eth.c net: drop the weight argument from netif_napi_add 2022-09-28 18:57:14 -07:00
hisi_femac.c net: hisilicon: Fix potential use-after-free in hisi_femac_rx() 2022-12-06 12:45:11 +01:00
hix5hd2_gmac.c net: hisilicon: Fix potential use-after-free in hix5hd2_rx() 2022-12-06 12:53:31 +01:00
hns_mdio.c net: hns: Separate C22 and C45 transactions 2023-01-17 19:34:08 -08:00
Kconfig ethernet: fix PTP_1588_CLOCK dependencies 2021-08-13 17:49:05 -07:00
Makefile