Initialize the `lasts' to NULL before calling strtok_r the first time.

With our strtok_r it's not necessary, but the man-page on SGIs says it
should be done.

Be more careful with the return value from strtok_r


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@1789 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
1997-06-01 03:13:48 +00:00
parent 3631f08c0a
commit daed744f7f

View File

@@ -267,7 +267,7 @@ parse_auth_level(char *str)
{
char *p;
int ret = 0;
char *foo;
char *foo = NULL;
for(p = strtok_r(str, ",", &foo);
p;
@@ -721,6 +721,7 @@ checkaccess(char *name)
FILE *fd;
int allowed = ALLOWED;
char *user, *perm, line[BUFSIZ];
char *foo;
fd = fopen(_PATH_FTPUSERS, "r");
@@ -728,10 +729,11 @@ checkaccess(char *name)
return allowed;
while (fgets(line, sizeof(line), fd) != NULL) {
user = strtok(line, " \t\n");
if (user[0] == '#')
foo = NULL;
user = strtok_r(line, " \t\n", &foo);
if (user == NULL || user[0] == '#')
continue;
perm = strtok(NULL, " \t\n");
perm = strtok_r(NULL, " \t\n", &foo);
if (match(user, name) == 0){
if(perm && strcmp(perm, "allow") == 0)
allowed = ALLOWED;