The directory and file name to store a user's report is produced by
replacing any character but the letters, digits and a few safe
characters from the user name. But that name mangling was not dealing
properly with consecutive invalid characters. The result was, at best,
a truncated file name (without any real consequence) or, at worst, an
invalid character left in the file name.
{
struct usergroupstruct *group, *last;
struct userinfostruct *user;
- int i, lastuser;
+ int i, j, lastuser;
int skip;
int flen;
int count, clen;
user->id[MAX_USER_LEN-1]='\0';
skip=0;
- for(i=0 ; userid[i] && i<MAX_USER_FNAME_LEN-1 ; i++) {
- if(isalnum(userid[i]) || userid[i]=='-' || userid[i]=='_') {
- user->filename[i]=userid[i];
+ j=0;
+ for (i=0 ; userid[i] && j<MAX_USER_FNAME_LEN-1 ; i++) {
+ if (isalnum(userid[i]) || userid[i]=='-' || userid[i]=='_') {
+ user->filename[j++]=userid[i];
skip=0;
} else {
if (!skip) {
- user->filename[i]='_';
+ user->filename[j++]='_';
skip=1;
}
}
}
- user->filename[i]='\0';
+ user->filename[j]='\0';
flen=i;
count=0;