[PATCH v2 18/22] net/ark: replace strtok with reentrant version
Jie Hai
haijie1 at huawei.com
Tue Nov 14 09:41:29 CET 2023
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: 9c7188a68d7b ("net/ark: provide API for hardware modules pktchkr and pktgen")
Cc: stable at dpdk.org
Signed-off-by: Jie Hai <haijie1 at huawei.com>
Acked-by: Chengwen Feng <fengchengwen at 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..c1c1033eb75e 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_s(args, toks, &sp);
+ v = strtok_s(NULL, toks, &sp);
while (argv && v) {
set_arg(argv, v);
- argv = strtok(NULL, toks);
- v = strtok(NULL, toks);
+ argv = strtok_s(NULL, toks, &sp);
+ v = strtok_s(NULL, toks, &sp);
}
}
diff --git a/drivers/net/ark/ark_pktgen.c b/drivers/net/ark/ark_pktgen.c
index 69ff7072b2ab..4b564099d2d6 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_s(args, toks, &sp);
+ v = strtok_s(NULL, toks, &sp);
while (argv && v) {
pmd_set_arg(argv, v);
- argv = strtok(NULL, toks);
- v = strtok(NULL, toks);
+ argv = strtok_s(NULL, toks, &sp);
+ v = strtok_s(NULL, toks, &sp);
}
}
--
2.30.0
More information about the dev
mailing list