total += strlen(name) + 1;
/* Allocate space for struct item, struct passwd and the strings. */
- item = emalloc(total);
+ item = ecalloc(1, total);
cp = (char *) item + sizeof(struct cache_item);
/*
errorx(1, _("unable to cache uid %u (%s), already exists"),
(unsigned int) uid, item->d.pw->pw_name);
} else {
- item = emalloc(sizeof(*item));
+ item = ecalloc(1, sizeof(*item));
item->refcnt = 1;
item->k.uid = uid;
- item->d.pw = NULL;
+ /* item->d.pw = NULL; */
if (rbinsert(pwcache_byuid, item) != NULL)
errorx(1, _("unable to cache uid %u, already exists"),
(unsigned int) uid);
errorx(1, _("unable to cache user %s, already exists"), name);
} else {
len = strlen(name) + 1;
- item = emalloc(sizeof(*item) + len);
+ item = ecalloc(1, sizeof(*item) + len);
item->refcnt = 1;
item->k.name = (char *) item + sizeof(*item);
memcpy(item->k.name, name, len);
- item->d.pw = NULL;
+ /* item->d.pw = NULL; */
if (rbinsert(pwcache_byname, item) != NULL)
errorx(1, _("unable to cache user %s, already exists"), name);
}
sizeof("/") /* pw_dir */ + sizeof(_PATH_BSHELL);
for (i = 0; i < 2; i++) {
- item = emalloc(len);
- zero_bytes(item, sizeof(*item) + sizeof(*pw));
+ item = ecalloc(1, len);
pw = (struct passwd *) ((char *)item + sizeof(*item));
pw->pw_uid = uid;
pw->pw_gid = gid;
if (name != NULL)
total += strlen(name) + 1;
- item = emalloc(total);
+ item = ecalloc(1, total);
cp = (char *) item + sizeof(struct cache_item);
/*
total += GROUPNAME_LEN * ngids;
again:
- item = emalloc(total);
+ item = ecalloc(1, total);
cp = (char *) item + sizeof(struct cache_item);
/*
* immediately after struct group to guarantee proper alignment.
*/
grlist = (struct group_list *)cp;
- zero_bytes(grlist, sizeof(struct group_list));
cp += sizeof(struct group_list);
grlist->groups = (char **)cp;
cp += sizeof(char *) * ngids;
errorx(1, _("unable to cache gid %u (%s), already exists"),
(unsigned int) gid, key.d.gr->gr_name);
} else {
- item = emalloc(sizeof(*item));
+ item = ecalloc(1, sizeof(*item));
item->refcnt = 1;
item->k.gid = gid;
- item->d.gr = NULL;
+ /* item->d.gr = NULL; */
if (rbinsert(grcache_bygid, item) != NULL)
errorx(1, _("unable to cache gid %u, already exists"),
(unsigned int) gid);
errorx(1, _("unable to cache group %s, already exists"), name);
} else {
len = strlen(name) + 1;
- item = emalloc(sizeof(*item) + len);
+ item = ecalloc(1, sizeof(*item) + len);
item->refcnt = 1;
item->k.name = (char *) item + sizeof(*item);
memcpy(item->k.name, name, len);
- item->d.gr = NULL;
+ /* item->d.gr = NULL; */
if (rbinsert(grcache_byname, item) != NULL)
errorx(1, _("unable to cache group %s, already exists"), name);
}
len = sizeof(*item) + sizeof(*gr) + namelen + 1;
for (i = 0; i < 2; i++) {
- item = emalloc(len);
- zero_bytes(item, sizeof(*item) + sizeof(*gr));
+ item = ecalloc(1, len);
gr = (struct group *) ((char *)item + sizeof(*item));
gr->gr_gid = (gid_t) atoi(group + 1);
gr->gr_name = (char *)gr + sizeof(struct group);
} else {
/* Should not happen. */
len = strlen(pw->pw_name) + 1;
- item = emalloc(sizeof(*item) + len);
+ item = ecalloc(1, sizeof(*item) + len);
item->refcnt = 1;
item->k.name = (char *) item + sizeof(*item);
memcpy(item->k.name, pw->pw_name, len);
- item->d.grlist = NULL;
+ /* item->d.grlist = NULL; */
if (rbinsert(grlist_cache, item) != NULL)
errorx(1, "unable to cache group list for %s, already exists",
pw->pw_name);