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