Merge from head. Move off-by-one buggy malloc()/safe_strcpy() combination to strdup...
authorJeremy Allison <jra@samba.org>
Mon, 24 Feb 2003 19:22:54 +0000 (19:22 +0000)
committerJeremy Allison <jra@samba.org>
Mon, 24 Feb 2003 19:22:54 +0000 (19:22 +0000)
Jeremy.
(This used to be commit 6521601bf8013c8809db13ccf7dd256ea4ad5dd7)

source3/lib/util_getent.c

index 7d45287bbad9d2a73cfcd33362a1474e90b42de0..ef01dd5947bbd841ac5654c9649691f0fd2c718a 100644 (file)
@@ -224,18 +224,16 @@ static struct sys_userlist *add_members_to_userlist(struct sys_userlist *list_he
 
        for (i = 0; i < num_users; i++) {
                struct sys_userlist *entry = (struct sys_userlist *)malloc(sizeof(*entry));
-               size_t len = strlen(grp->gr_mem[i])+1;
                if (entry == NULL) {
                        free_userlist(list_head);
                        return NULL;
                }
-               entry->unix_name = (char *)malloc(len);
+               entry->unix_name = strdup(grp->gr_mem[i]);
                if (entry->unix_name == NULL) {
                        SAFE_FREE(entry);
                        free_userlist(list_head);
                        return NULL;
                }
-               safe_strcpy(entry->unix_name, grp->gr_mem[i],len);
                DLIST_ADD(list_head, entry);
        }
        return list_head;