[PATCH v5 22/25] net/mlx5: replace strtok with reentrant version
Jie Hai
haijie1 at huawei.com
Fri Nov 8 12:04:01 CET 2024
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: 0683c002f7f5 ("net/mlx5: add testpmd commands for GENEVE TLV parser")
Signed-off-by: Jie Hai <haijie1 at huawei.com>
---
drivers/net/mlx5/mlx5_testpmd.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/net/mlx5/mlx5_testpmd.c b/drivers/net/mlx5/mlx5_testpmd.c
index 1bb5a89559fe..7bd220fafa46 100644
--- a/drivers/net/mlx5/mlx5_testpmd.c
+++ b/drivers/net/mlx5/mlx5_testpmd.c
@@ -353,6 +353,7 @@ mlx5_test_parse_geneve_option_data(const char *buff, uint8_t data_len,
rte_be32_t **match_data_mask)
{
rte_be32_t *data;
+ char *sp = NULL;
char *buff2;
char *token;
uint8_t i = 0;
@@ -377,7 +378,7 @@ mlx5_test_parse_geneve_option_data(const char *buff, uint8_t data_len,
return -ENOMEM;
}
- token = strtok(buff2, SPACE_DELIMITER);
+ token = strtok_r(buff2, SPACE_DELIMITER, &sp);
while (token != NULL) {
if (i == data_len) {
TESTPMD_LOG(ERR,
@@ -393,7 +394,7 @@ mlx5_test_parse_geneve_option_data(const char *buff, uint8_t data_len,
else
data[i] = 0x0;
- token = strtok(NULL, SPACE_DELIMITER);
+ token = strtok_r(NULL, SPACE_DELIMITER, &sp);
i++;
}
--
2.22.0
More information about the dev
mailing list