> -----Original Message----- > From: Jie Hai <[email protected]> > Sent: Tuesday, November 14, 2023 4:30 PM > To: [email protected]; Anatoly Burakov <[email protected]>; Amit > Prakash Shukla <[email protected]> > Cc: [email protected]; [email protected]; > [email protected] > Subject: [EXT] [PATCH v3 10/22] eal: replace strtok with reentrant version > > External Email > > ---------------------------------------------------------------------- > 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: 2054f31a1fcd ("mem: add memseg info in telemetry") > Cc: [email protected] > > Signed-off-by: Jie Hai <[email protected]> > Acked-by: Chengwen Feng <[email protected]> > --- > lib/eal/common/eal_common_memory.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/lib/eal/common/eal_common_memory.c > b/lib/eal/common/eal_common_memory.c > index d9433db62345..a05eb0442b0b 100644 > --- a/lib/eal/common/eal_common_memory.c > +++ b/lib/eal/common/eal_common_memory.c > @@ -1273,22 +1273,22 @@ parse_params(const char *params, uint32_t > *vals, size_t n_vals) > char dlim[2] = ","; > char *params_args; > size_t count = 0; > - char *token; > + char *token, *sp = NULL; > > if (vals == NULL || params == NULL || strlen(params) == 0) > return -1; > > - /* strtok expects char * and param is const char *. Hence on using > + /* strtok_r expects char * and param is const char *. Hence on using > * params as "const char *" compiler throws warning. > */ > params_args = strdup(params); > if (params_args == NULL) > return -1; > > - token = strtok(params_args, dlim); > + token = strtok_r(params_args, dlim, &sp); > while (token && isdigit(*token) && count < n_vals) { > vals[count++] = strtoul(token, NULL, 10); > - token = strtok(NULL, dlim); > + token = strtok_r(NULL, dlim, &sp); > } > > free(params_args); > -- > 2.30.0
Acked-by: Amit Prakash Shukla <[email protected]>

