From bcfa72dbac2b0a960b417911cb9d47713e2d0fa4 Mon Sep 17 00:00:00 2001 From: SashaXser <24498484+SashaXser@users.noreply.github.com> Date: Mon, 27 Nov 2023 22:12:13 +0400 Subject: [PATCH] Update goodbyedpi.c --- src/goodbyedpi.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/goodbyedpi.c b/src/goodbyedpi.c index 0da5f380..6983282a 100644 --- a/src/goodbyedpi.c +++ b/src/goodbyedpi.c @@ -813,15 +813,17 @@ int main(int argc, char *argv[]) { char *autottl_copy = strdup(optarg); if (strchr(autottl_copy, '-')) { // token "-" found, start X-Y parser - char *autottl_current = strtok(autottl_copy, "-"); + char *autottl_current; + char *saveptr; // declare a pointer to store the state of strtok_r + autottl_current = strtok_r(autottl_copy, "-", &saveptr); // use strtok_r instead of strtok auto_ttl_1 = atoub(autottl_current, "Set Auto TTL parameter error!"); - autottl_current = strtok(NULL, "-"); + autottl_current = strtok_r(NULL, "-", &saveptr); // use strtok_r instead of strtok if (!autottl_current) { puts("Set Auto TTL parameter error!"); exit(EXIT_FAILURE); } auto_ttl_2 = atoub(autottl_current, "Set Auto TTL parameter error!"); - autottl_current = strtok(NULL, "-"); + autottl_current = strtok_r(NULL, "-", &saveptr); // use strtok_r instead of strtok if (!autottl_current) { puts("Set Auto TTL parameter error!"); exit(EXIT_FAILURE);