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/latencystats/rte_latencystats.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
@@ -220,6 +220,7 @@ rte_latencystats_init(uint64_t app_samp_intvl,
struct rxtx_cbs *cbs = NULL;
const char *ptr_strings[NUM_LATENCY_STATS] = {0};
const struct rte_memzone *mz = NULL;
+ char errmsg[RTE_STRERR_BUFSIZE];
const unsigned int flags = 0;
int ret;
@@ -266,9 +267,11 @@ rte_latencystats_init(uint64_t app_samp_intvl,
ret = rte_eth_dev_info_get(pid, &dev_info);
if (ret != 0) {
+ if (strerror_r(-ret, errmsg, sizeof(errmsg)) != 0)
+ snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -ret);
LATENCY_STATS_LOG(INFO,
"Error during getting device (port %u) info: %s",
- pid, strerror(-ret));
+ pid, errmsg);
continue;
}
@@ -303,6 +306,7 @@ rte_latencystats_uninit(void)
int ret = 0;
struct rxtx_cbs *cbs = NULL;
const struct rte_memzone *mz = NULL;
+ char errmsg[RTE_STRERR_BUFSIZE];
/** De register Rx/Tx callbacks */
RTE_ETH_FOREACH_DEV(pid) {
@@ -310,9 +314,11 @@ rte_latencystats_uninit(void)
ret = rte_eth_dev_info_get(pid, &dev_info);
if (ret != 0) {
+ if (strerror_r(-ret, errmsg, sizeof(errmsg)) != 0)
+ snprintf(errmsg, sizeof(errmsg), "Unknown error %d", -ret);
LATENCY_STATS_LOG(INFO,
"Error during getting device (port %u) info: %s",
- pid, strerror(-ret));
+ pid, errmsg);
continue;
}