]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Mangled file name is really unique
authorFrederic Marchal <fmarchal@users.sourceforge.net>
Fri, 4 Jan 2013 18:47:16 +0000 (19:47 +0100)
committerFrederic Marchal <fmarchal@users.sourceforge.net>
Fri, 4 Jan 2013 18:47:16 +0000 (19:47 +0100)
Due to an error, the file name created by mangling the user ID was not
using the suffix that was supposed to make it unique. Therefore, user's
names made of several consecutive non alphanumeric characters were not
unique.

The error manifested itself as an error message saying that the
_.user_unsort file could not be sorted. It occurred after the first
user assigned to the _ file name had been sorted and its file deleted.
Therefore any subsequent user sharing the _ file name would fail.

This patch also makes sure no original user name might possibly ends up
being the same as a mangled name.

userinfo.c

index a92ea9368d66cf47b359595bf3c42bd169c2743d..25e05f3b851b12fc7e2b923fdf12dc3a2cb21803 100644 (file)
@@ -125,15 +125,15 @@ struct userinfostruct *userinfo_create(const char *userid)
                        }
                }
                if (j==0) filename[j++]='_'; //don't leave a file name empty
+               flen=j;
                filename[j]='\0';
-               flen=i-1;
 
                count=0;
                for (group=first_user_group ; group ; group=group->next) {
                        lastuser=(group->next) ? group->nusers : group->nusers-1;
                        for (i=0 ; i<lastuser ; i++) {
                                if (strcasecmp(filename,group->list[i].filename)==0) {
-                                       clen=sprintf(cstr,"-%04X",count++);
+                                       clen=sprintf(cstr,"+%X",count++);
                                        if (flen+clen<MAX_USER_FNAME_LEN)
                                                strcpy(filename+flen,cstr);
                                        else