summaryrefslogtreecommitdiff
path: root/source3/lib/util_getent.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2004-12-07 18:25:53 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:53:32 -0500
commitacf9d61421faa6c0055d57fdee7db300dc5431aa (patch)
tree5482afecfe9b4a68b9a1f18d541a3109f8143ab7 /source3/lib/util_getent.c
parent3bd3be97dc8a581c0502410453091c195e322766 (diff)
downloadsamba-acf9d61421faa6c0055d57fdee7db300dc5431aa.tar.gz
samba-acf9d61421faa6c0055d57fdee7db300dc5431aa.tar.bz2
samba-acf9d61421faa6c0055d57fdee7db300dc5431aa.zip
r4088: Get medieval on our ass about malloc.... :-). Take control of all our allocation
functions so we can funnel through some well known functions. Should help greatly with malloc checking. HEAD patch to follow. Jeremy. (This used to be commit 620f2e608f70ba92f032720c031283d295c5c06a)
Diffstat (limited to 'source3/lib/util_getent.c')
-rw-r--r--source3/lib/util_getent.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/source3/lib/util_getent.c b/source3/lib/util_getent.c
index 4431d6a2a4..1b01cae5fa 100644
--- a/source3/lib/util_getent.c
+++ b/source3/lib/util_getent.c
@@ -33,7 +33,7 @@ struct sys_grent * getgrent_list(void)
struct sys_grent *gent;
struct group *grp;
- gent = (struct sys_grent *) malloc(sizeof(struct sys_grent));
+ gent = SMB_MALLOC_P(struct sys_grent);
if (gent == NULL) {
DEBUG (0, ("Out of memory in getgrent_list!\n"));
return NULL;
@@ -53,11 +53,11 @@ struct sys_grent * getgrent_list(void)
int i,num;
if (grp->gr_name) {
- if ((gent->gr_name = strdup(grp->gr_name)) == NULL)
+ if ((gent->gr_name = SMB_STRDUP(grp->gr_name)) == NULL)
goto err;
}
if (grp->gr_passwd) {
- if ((gent->gr_passwd = strdup(grp->gr_passwd)) == NULL)
+ if ((gent->gr_passwd = SMB_STRDUP(grp->gr_passwd)) == NULL)
goto err;
}
gent->gr_gid = grp->gr_gid;
@@ -67,20 +67,20 @@ struct sys_grent * getgrent_list(void)
;
/* alloc space for gr_mem string pointers */
- if ((gent->gr_mem = (char **) malloc((num+1) * sizeof(char *))) == NULL)
+ if ((gent->gr_mem = SMB_MALLOC_ARRAY(char *, num+1)) == 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)
+ if ((gent->gr_mem[i] = SMB_STRDUP(grp->gr_mem[i])) == NULL)
goto err;
}
gent->gr_mem[num] = NULL;
grp = getgrent();
if (grp) {
- gent->next = (struct sys_grent *) malloc(sizeof(struct sys_grent));
+ gent->next = SMB_MALLOC_P(struct sys_grent);
if (gent->next == NULL)
goto err;
gent = gent->next;
@@ -134,7 +134,7 @@ struct sys_pwent * getpwent_list(void)
struct sys_pwent *pent;
struct passwd *pwd;
- pent = (struct sys_pwent *) malloc(sizeof(struct sys_pwent));
+ pent = SMB_MALLOC_P(struct sys_pwent);
if (pent == NULL) {
DEBUG (0, ("Out of memory in getpwent_list!\n"));
return NULL;
@@ -146,31 +146,31 @@ struct sys_pwent * getpwent_list(void)
while (pwd != NULL) {
memset(pent, '\0', sizeof(struct sys_pwent));
if (pwd->pw_name) {
- if ((pent->pw_name = strdup(pwd->pw_name)) == NULL)
+ if ((pent->pw_name = SMB_STRDUP(pwd->pw_name)) == NULL)
goto err;
}
if (pwd->pw_passwd) {
- if ((pent->pw_passwd = strdup(pwd->pw_passwd)) == NULL)
+ if ((pent->pw_passwd = SMB_STRDUP(pwd->pw_passwd)) == NULL)
goto err;
}
pent->pw_uid = pwd->pw_uid;
pent->pw_gid = pwd->pw_gid;
if (pwd->pw_gecos) {
- if ((pent->pw_gecos = strdup(pwd->pw_gecos)) == NULL)
+ if ((pent->pw_gecos = SMB_STRDUP(pwd->pw_gecos)) == NULL)
goto err;
}
if (pwd->pw_dir) {
- if ((pent->pw_dir = strdup(pwd->pw_dir)) == NULL)
+ if ((pent->pw_dir = SMB_STRDUP(pwd->pw_dir)) == NULL)
goto err;
}
if (pwd->pw_shell) {
- if ((pent->pw_shell = strdup(pwd->pw_shell)) == NULL)
+ if ((pent->pw_shell = SMB_STRDUP(pwd->pw_shell)) == NULL)
goto err;
}
pwd = getpwent();
if (pwd) {
- pent->next = (struct sys_pwent *) malloc(sizeof(struct sys_pwent));
+ pent->next = SMB_MALLOC_P(struct sys_pwent);
if (pent->next == NULL)
goto err;
pent = pent->next;
@@ -223,12 +223,12 @@ 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));
+ struct sys_userlist *entry = SMB_MALLOC_P(struct sys_userlist);
if (entry == NULL) {
free_userlist(list_head);
return NULL;
}
- entry->unix_name = (char *)strdup(grp->gr_mem[i]);
+ entry->unix_name = (char *)SMB_STRDUP(grp->gr_mem[i]);
if (entry->unix_name == NULL) {
SAFE_FREE(entry);
free_userlist(list_head);