From 1b3a41250e1a5f36dcd618ce51f8dac50335443c Mon Sep 17 00:00:00 2001 From: Klas Lindfors Date: Thu, 27 Nov 2014 15:43:16 +0100 Subject: [PATCH] change strtok usage to strtok_r --- util.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/util.c b/util.c index ecfacf6..ce636ba 100644 --- a/util.c +++ b/util.c @@ -141,11 +141,12 @@ check_user_token (const char *authfile, retval = -2; while (fgets (buf, 1024, opwfile)) { + char *saveptr = NULL; if (buf[strlen (buf) - 1] == '\n') buf[strlen (buf) - 1] = '\0'; if(verbose) D (("Authorization line: %s", buf)); - s_user = strtok (buf, ":"); + s_user = strtok_r (buf, ":", &saveptr); if (s_user && strcmp (username, s_user) == 0) { if(verbose) @@ -153,7 +154,7 @@ check_user_token (const char *authfile, retval = -1; //We found at least one line for the user do { - s_token = strtok (NULL, ":"); + s_token = strtok_r (NULL, ":", &saveptr); if(verbose) D (("Authorization token: %s", s_token)); if (s_token && strcmp (otp_id, s_token) == 0)