[Cvs-nserver-commits] CVS: cvs-nserver/acl check_user_acl.c,1.1.2.1,1.1.2.2 user-acl.c,1.1.2.2,1.1.2
Brought to you by:
tyranny
From: Alexey M. <ty...@us...> - 2001-09-08 23:04:40
|
Update of /cvsroot/cvs-nserver/cvs-nserver/acl In directory usw-pr-cvs1:/tmp/cvs-serv27392 Modified Files: Tag: NCLI-1-11-1 check_user_acl.c user-acl.c Log Message: Make our own copy of username Index: check_user_acl.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/check_user_acl.c,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -d -r1.1.2.1 -r1.1.2.2 --- check_user_acl.c 2001/08/29 17:28:11 1.1.2.1 +++ check_user_acl.c 2001/09/08 23:04:36 1.1.2.2 @@ -7,6 +7,7 @@ int main (void) { + char ann[] = "ann"; USER_ACL *user_acl = NULL; USER_ACE *user_ace; @@ -16,10 +17,12 @@ assert(user_ace == NULL); /* set permissions for user */ - user_acl = set_user_ace (NULL, "ann", 10); + user_acl = set_user_ace (NULL, ann, 10); assert(user_acl != NULL); + strcpy(ann, "xxx"); - /* check that they are the same as were set */ + /* check that they are the same as were set, even if the original + username gets overwritten */ user_ace = get_user_ace (user_acl, "ann"); assert(user_ace != NULL); assert(user_ace->perm == 10); Index: user-acl.c =================================================================== RCS file: /cvsroot/cvs-nserver/cvs-nserver/acl/Attic/user-acl.c,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -d -r1.1.2.2 -r1.1.2.3 --- user-acl.c 2001/08/29 19:56:54 1.1.2.2 +++ user-acl.c 2001/09/08 23:04:36 1.1.2.3 @@ -15,12 +15,14 @@ */ +#define _BSD_SOURCE 1 #include "config.h" #include "user-acl.h" #include <stdlib.h> +#include <string.h> USER_ACE * get_user_ace (USER_ACL *acls, char *username) @@ -49,11 +51,15 @@ acl = acl->next; } - acl = (USER_ACL *) malloc(sizeof(USER_ACE)); + acl = (USER_ACL *) calloc(1, sizeof(USER_ACE)); if (acl == NULL) return NULL; - acl->username = username; + acl->username = strdup(username); + if (acl->username == NULL) { + free(acl); + return NULL; + } acl->perm = perm; acl->next = acls; |