summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--source/lib/util_getent.c20
-rw-r--r--source/rpc_server/srv_samr_nt.c12
2 files changed, 19 insertions, 13 deletions
diff --git a/source/lib/util_getent.c b/source/lib/util_getent.c
index 4123be8e24c..7223cf834d9 100644
--- a/source/lib/util_getent.c
+++ b/source/lib/util_getent.c
@@ -37,14 +37,20 @@ struct sys_grent * getgrent_list(void)
DEBUG (0, ("Out of memory in getgrent_list!\n"));
return NULL;
}
+ memset(gent, '\0', sizeof(struct sys_grent));
glist = gent;
setgrent();
grp = getgrent();
+ if (grp == NULL) {
+ endgrent();
+ free(glist);
+ return NULL;
+ }
+
while (grp != NULL) {
int i,num;
- memset(gent, '\0', sizeof(struct sys_grent));
if (grp->gr_name) {
if ((gent->gr_name = strdup(grp->gr_name)) == NULL)
goto err;
@@ -63,6 +69,8 @@ struct sys_grent * getgrent_list(void)
if ((gent->gr_mem = (char **) malloc(num+1 * sizeof(char *))) == NULL)
goto err;
+ memset(gent->gr_mem, '\0', num+1 * sizeof(char *));
+
for (i=0; i < num; i++) {
if ((gent->gr_mem[i] = strdup(grp->gr_mem[i])) == NULL)
goto err;
@@ -75,6 +83,7 @@ struct sys_grent * getgrent_list(void)
if (gent->next == NULL)
goto err;
gent = gent->next;
+ memset(gent, '\0', sizeof(struct sys_grent));
}
}
@@ -97,7 +106,6 @@ struct sys_grent * getgrent_list(void)
void grent_free (struct sys_grent *glist)
{
while (glist) {
- char **ary;
struct sys_grent *temp;
if (glist->gr_name)
@@ -105,11 +113,9 @@ void grent_free (struct sys_grent *glist)
if (glist->gr_passwd)
free(glist->gr_passwd);
if (glist->gr_mem) {
- ary = glist->gr_mem;
- while (*ary) {
- free(*ary);
- ary++;
- }
+ int i;
+ for (i = 0; glist->gr_mem[i]; i++)
+ free(glist->gr_mem[i]);
free(glist->gr_mem);
}
temp = glist->next;
diff --git a/source/rpc_server/srv_samr_nt.c b/source/rpc_server/srv_samr_nt.c
index a8dcf728103..ca600947a9d 100644
--- a/source/rpc_server/srv_samr_nt.c
+++ b/source/rpc_server/srv_samr_nt.c
@@ -775,18 +775,18 @@ static BOOL get_group_alias_entries(DOMAIN_GRP *d_grp, DOM_SID *sid, uint32 star
/* well-known aliases */
if (strequal(sid_str, "S-1-5-32")) {
- char *name;
+ char *alias_name;
while (!lp_hide_local_users() &&
num_entries < max_entries &&
- ((name = builtin_alias_rids[num_entries].name) != NULL)) {
+ ((alias_name = builtin_alias_rids[num_entries].name) != NULL)) {
- fstrcpy(d_grp[num_entries].name, name);
+ fstrcpy(d_grp[num_entries].name, alias_name);
d_grp[num_entries].rid = builtin_alias_rids[num_entries].rid;
num_entries++;
}
} else if (strequal(sid_str, sam_sid_str) && !lp_hide_local_users()) {
- char *name;
+ fstring name;
char *sep;
struct sys_grent *glist;
struct sys_grent *grp;
@@ -796,7 +796,7 @@ static BOOL get_group_alias_entries(DOMAIN_GRP *d_grp, DOM_SID *sid, uint32 star
/* local aliases */
/* we return the UNIX groups here. This seems to be the right */
/* thing to do, since NT member servers return their local */
- /* groups in the same situation. */
+ /* groups in the same situation. */
/* use getgrent_list() to retrieve the list of groups to avoid
* problems with getgrent possible infinite loop by internal
@@ -808,8 +808,8 @@ static BOOL get_group_alias_entries(DOMAIN_GRP *d_grp, DOM_SID *sid, uint32 star
for (;(num_entries < max_entries) && (grp != NULL); grp = grp->next) {
int i;
uint32 trid;
- name = grp->gr_name;
+ fstrcpy(name,grp->gr_name);
DEBUG(10,("get_group_alias_entries: got group %s\n", name ));
/* Don't return winbind groups as they are not local! */