Multiple threads calling the same function may cause condition
race issues, which often leads to abnormal behavior and can cause
more serious vulnerabilities such as abnormal termination, denial
of service, and compromised data integrity.
The strtok() is non-reentrant, it is better to replace it with a
reentrant version.
Fixes: 3a04ecb21420 ("examples/vhost: add async vhost args parsing")
Cc: [email protected]
Signed-off-by: Jie Hai <[email protected]>
Acked-by: Chengwen Feng <[email protected]>
---
examples/vhost/main.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index ce5c1efddf5c..3949d83be212 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -246,6 +246,7 @@ open_dma(const char *value)
char *ptrs[2];
char *start, *end, *substr;
int64_t socketid, vring_id;
+ char *sp = NULL;
struct rte_dma_info info;
struct rte_dma_conf dev_config = { .nb_vchans = 1 };
@@ -269,7 +270,7 @@ open_dma(const char *value)
/* process DMA devices within bracket. */
addrs++;
- substr = strtok(addrs, ";]");
+ substr = strtok_s(addrs, ";]", &sp);
if (!substr) {
ret = -1;
goto out;
--
2.30.0