The function strerror() is insecure in a multi-thread environment. This patch uses strerror_r() to replace it.
Signed-off-by: Dengdui Huang <huangdeng...@huawei.com> Acked-by: Chengwen Feng <fengcheng...@huawei.com> Acked-by: Morten Brørup <m...@smartsharesystems.com> Acked-by: Huisong Li <lihuis...@huawei.com> --- drivers/common/mlx5/linux/mlx5_nl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/common/mlx5/linux/mlx5_nl.c b/drivers/common/mlx5/linux/mlx5_nl.c index a5ac4dc543..67fc6c08d9 100644 --- a/drivers/common/mlx5/linux/mlx5_nl.c +++ b/drivers/common/mlx5/linux/mlx5_nl.c @@ -1924,18 +1924,21 @@ mlx5_nl_read_events(int nlsk_fd, mlx5_nl_event_cb *cb, void *cb_arg) .msg_iov = &iov, .msg_iovlen = 1, }; + char errmsg[RTE_STRERR_BUFSIZE]; struct nlmsghdr *hdr; ssize_t size; while (1) { size = recvmsg(nlsk_fd, &msg, MSG_DONTWAIT); if (size < 0) { + if (strerror_r(errno, errmsg, sizeof(errmsg)) != 0) + snprintf(errmsg, sizeof(errmsg), "Unknown error %d", errno); if (errno == EAGAIN) return 0; if (errno == EINTR) continue; DRV_LOG(DEBUG, "Failed to receive netlink message: %s", - strerror(errno)); + errmsg); rte_errno = errno; return -rte_errno; } -- 2.33.0