The function strerror() is insecure in a multi-thread environment.
This patch uses strerror_r() to replace it.
Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Huisong Li <lihuisong@huawei.com>
---
lib/pdump/rte_pdump.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
@@ -284,6 +284,7 @@ static int
set_pdump_rxtx_cbs(const struct pdump_request *p)
{
uint16_t nb_rx_q = 0, nb_tx_q = 0, end_q, queue;
+ char errmsg[RTE_STRERR_BUFSIZE];
uint16_t port;
int ret = 0;
struct rte_bpf *filter = NULL;
@@ -335,9 +336,11 @@ set_pdump_rxtx_cbs(const struct pdump_request *p)
ret = rte_eth_dev_info_get(port, &dev_info);
if (ret != 0) {
+ if (strerror_r(-ret, errmsg, sizeof(errmsg)) != 0)
+ snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -ret);
PDUMP_LOG_LINE(ERR,
"Error during getting device (port %u) info: %s",
- port, strerror(-ret));
+ port, errmsg);
return ret;
}
@@ -731,15 +734,18 @@ int
rte_pdump_stats(uint16_t port, struct rte_pdump_stats *stats)
{
struct rte_eth_dev_info dev_info;
+ char errmsg[RTE_STRERR_BUFSIZE];
const struct rte_memzone *mz;
int ret;
memset(stats, 0, sizeof(*stats));
ret = rte_eth_dev_info_get(port, &dev_info);
if (ret != 0) {
+ if (strerror_r(-ret, errmsg, sizeof(errmsg)) != 0)
+ snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -ret);
PDUMP_LOG_LINE(ERR,
"Error during getting device (port %u) info: %s",
- port, strerror(-ret));
+ port, errmsg);
return ret;
}