diff options
-rw-r--r-- | lib/libskey/put.c | 7 | ||||
-rw-r--r-- | lib/libskey/skeyaccess.c | 9 | ||||
-rw-r--r-- | lib/libskey/skeylogin.c | 37 |
3 files changed, 39 insertions, 14 deletions
diff --git a/lib/libskey/put.c b/lib/libskey/put.c index d533714..6619f73 100644 --- a/lib/libskey/put.c +++ b/lib/libskey/put.c @@ -2106,7 +2106,7 @@ etob(out, e) char *out; char *e; { - char *word; + char *word, *cp; int i, p, v,l, low,high; char b[9]; char input[36]; @@ -2115,10 +2115,13 @@ char *e; return -1; strncpy(input,e,sizeof(input)); + cp = input; memset(b, 0, sizeof(b)); memset(out, 0, 8); for(i=0,p=0;i<6;i++,p+=11){ - if((word = strtok(i == 0 ? input : NULL," ")) == NULL) + while ((word = strsep(&cp, " ")) != NULL && *word == '\0') + ; + if (word == NULL) return -1; l = strlen(word); if(l > 4 || l < 1){ diff --git a/lib/libskey/skeyaccess.c b/lib/libskey/skeyaccess.c index 3cd877f..170da6c 100644 --- a/lib/libskey/skeyaccess.c +++ b/lib/libskey/skeyaccess.c @@ -44,6 +44,7 @@ * Token input with one-deep pushback. */ static char *prev_token = 0; /* push-back buffer */ +static char *line_pointer = NULL; static char *first_token(); static int line_number; static void unget_token(); @@ -286,7 +287,10 @@ FILE *fp; if (buf[0]) printf("rule: %s\n", buf); #endif - if (cp = strtok(buf, " \t")) + line_pointer = buf; + while ((cp = strsep(&line_pointer, " \t")) != NULL && *cp == '\0') + ; + if (cp != NULL) return (cp); } } @@ -308,7 +312,8 @@ static char *get_token() if (cp = prev_token) { prev_token = 0; } else { - cp = strtok((char *) 0, " \t"); + while ((cp = strsep(&line_pointer, " \t")) != NULL && *cp == '\0') + ; } return (cp); } diff --git a/lib/libskey/skeylogin.c b/lib/libskey/skeylogin.c index e15edb5..217c674 100644 --- a/lib/libskey/skeylogin.c +++ b/lib/libskey/skeylogin.c @@ -100,7 +100,7 @@ char *name; int found; int len; long recstart; - char *cp; + char *cp, *p; struct stat statbuf; /* See if the _PATH_SKEYFILE exists, and create it if not */ @@ -127,14 +127,23 @@ char *name; rip(mp->buf); if(mp->buf[0] == '#') continue; /* Comment */ - if((mp->logname = strtok(mp->buf," \t")) == NULL) + p = mp->buf; + while ((cp = strsep(&p, " \t")) != NULL && *cp == '\0') + ; + if((mp->logname = cp) == NULL) continue; - if((cp = strtok(NULL," \t")) == NULL) + while ((cp = strsep(&p, " \t")) != NULL && *cp == '\0') + ; + if(cp == NULL) continue; mp->n = atoi(cp); - if((mp->seed = strtok(NULL," \t")) == NULL) + while ((cp = strsep(&p, " \t")) != NULL && *cp == '\0') + ; + if((mp->seed = cp) == NULL) continue; - if((mp->val = strtok(NULL," \t")) == NULL) + while ((cp = strsep(&p, " \t")) != NULL && *cp == '\0') + ; + if((mp->val = cp) == NULL) continue; if(strlen(mp->logname) == len && strncmp(mp->logname,name,len) == 0){ @@ -173,7 +182,7 @@ long microsec; char tbuf[27],buf[60]; char me[80]; int rval; - char *cp; + char *cp, *p; time(&now); tm = localtime(&now); @@ -215,10 +224,18 @@ long microsec; return -1; } rip(mp->buf); - mp->logname = strtok(mp->buf," \t"); - cp = strtok(NULL," \t") ; - mp->seed = strtok(NULL," \t"); - mp->val = strtok(NULL," \t"); + p = mp->buf; + while ((cp = strsep(&p, " \t")) != NULL && *cp == '\0') + ; + mp->logname = cp; + while ((cp = strsep(&p, " \t")) != NULL && *cp == '\0') + ; + while ((cp = strsep(&p, " \t")) != NULL && *cp == '\0') + ; + mp->seed = cp; + while ((cp = strsep(&p, " \t")) != NULL && *cp == '\0') + ; + mp->val = cp; /* And convert file value to hex for comparison */ atob8(filekey,mp->val); |