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 function.

Signed-off-by: Jie Hai <haij...@huawei.com>
---
 drivers/net/ark/ark_pktchkr.c | 10 +++++-----
 drivers/net/ark/ark_pktgen.c  | 10 +++++-----
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ark/ark_pktchkr.c b/drivers/net/ark/ark_pktchkr.c
index e1f336c73c2a..6e8e5339607b 100644
--- a/drivers/net/ark/ark_pktchkr.c
+++ b/drivers/net/ark/ark_pktchkr.c
@@ -359,14 +359,14 @@ set_arg(char *arg, char *val)
 void
 ark_pktchkr_parse(char *args)
 {
-       char *argv, *v;
+       char *argv, *v, *sp = NULL;
        const char toks[] = "=\n\t\v\f \r";
-       argv = strtok(args, toks);
-       v = strtok(NULL, toks);
+       argv = strtok_r(args, toks, &sp);
+       v = strtok_r(NULL, toks, &sp);
        while (argv && v) {
                set_arg(argv, v);
-               argv = strtok(NULL, toks);
-               v = strtok(NULL, toks);
+               argv = strtok_r(NULL, toks, &sp);
+               v = strtok_r(NULL, toks, &sp);
        }
 }
 
diff --git a/drivers/net/ark/ark_pktgen.c b/drivers/net/ark/ark_pktgen.c
index 69ff7072b2ab..d611406a1b46 100644
--- a/drivers/net/ark/ark_pktgen.c
+++ b/drivers/net/ark/ark_pktgen.c
@@ -340,14 +340,14 @@ pmd_set_arg(char *arg, char *val)
 void
 ark_pktgen_parse(char *args)
 {
-       char *argv, *v;
+       char *argv, *v, *sp = NULL;
        const char toks[] = " =\n\t\v\f \r";
-       argv = strtok(args, toks);
-       v = strtok(NULL, toks);
+       argv = strtok_r(args, toks, &sp);
+       v = strtok_r(NULL, toks, &sp);
        while (argv && v) {
                pmd_set_arg(argv, v);
-               argv = strtok(NULL, toks);
-               v = strtok(NULL, toks);
+               argv = strtok_r(NULL, toks, &sp);
+               v = strtok_r(NULL, toks, &sp);
        }
 }
 
-- 
2.30.0

Reply via email to