[v5,24/25] examples/vhost: replace strtok with reentrant version
Checks
Commit Message
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: 53d3f4778c1d ("vhost: integrate dmadev in asynchronous data-path")
Signed-off-by: Jie Hai <haijie1@huawei.com>
---
examples/vhost/main.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
@@ -29,6 +29,7 @@
#include <rte_dmadev.h>
#include <rte_vhost_async.h>
#include <rte_thread.h>
+#include <rte_os_shim.h>
#include "main.h"
@@ -259,6 +260,7 @@ open_dma(const char *value)
uint16_t i = 0;
char *dma_arg[RTE_MAX_VHOST_DEVICE];
int args_nr;
+ char *sp = NULL;
if (input == NULL)
return -1;
@@ -272,7 +274,7 @@ open_dma(const char *value)
/* process DMA devices within bracket. */
addrs++;
- substr = strtok(addrs, ";]");
+ substr = strtok_r(addrs, ";]", &sp);
if (!substr) {
ret = -1;
goto out;