From: Frédéric Marchal Date: Mon, 27 Dec 2010 12:30:34 +0000 (+0000) Subject: Fix creation of the report's file name from the mangling of the user name X-Git-Tag: v2.3.2~104 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d09d93c695563e91bf7ff071f9072079063aaeb5;p=thirdparty%2Fsarg.git Fix creation of the report's file name from the mangling of the user name 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. --- diff --git a/userinfo.c b/userinfo.c index 6d82aa1..089a641 100644 --- a/userinfo.c +++ b/userinfo.c @@ -61,7 +61,7 @@ struct userinfostruct *userinfo_create(const char *userid) { struct usergroupstruct *group, *last; struct userinfostruct *user; - int i, lastuser; + int i, j, lastuser; int skip; int flen; int count, clen; @@ -91,18 +91,19 @@ struct userinfostruct *userinfo_create(const char *userid) user->id[MAX_USER_LEN-1]='\0'; skip=0; - for(i=0 ; userid[i] && ifilename[i]=userid[i]; + j=0; + for (i=0 ; userid[i] && jfilename[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;