From daed744f7f27c6c3273a47855cec403a933813ea Mon Sep 17 00:00:00 2001 From: Assar Westerlund Date: Sun, 1 Jun 1997 03:13:48 +0000 Subject: [PATCH] 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 --- appl/ftp/ftpd/ftpd.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/appl/ftp/ftpd/ftpd.c b/appl/ftp/ftpd/ftpd.c index be6726bb1..d9d63b01d 100644 --- a/appl/ftp/ftpd/ftpd.c +++ b/appl/ftp/ftpd/ftpd.c @@ -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;