static char errbuf[512];
struct alias *a;
- a = emalloc(sizeof(*a));
+ a = ecalloc(1, sizeof(*a));
a->name = name;
a->type = type;
- a->seqno = 0;
+ /* a->seqno = 0; */
list2tq(&a->members, members);
if (rbinsert(aliases, a)) {
snprintf(errbuf, sizeof(errbuf), "Alias `%s' already defined", name);
/* Add new node to the head of the list. */
if (op == add) {
- cur = emalloc(sizeof(struct list_member));
+ cur = ecalloc(1, sizeof(struct list_member));
cur->value = emalloc(len + 1);
(void) memcpy(cur->value, val, len);
cur->value[len] = '\0';
/* Fill in the "env_delete" list. */
for (p = initial_badenv_table; *p; p++) {
- cur = emalloc(sizeof(struct list_member));
+ cur = ecalloc(1, sizeof(struct list_member));
cur->value = estrdup(*p);
cur->next = def_env_delete;
def_env_delete = cur;
/* Fill in the "env_check" list. */
for (p = initial_checkenv_table; *p; p++) {
- cur = emalloc(sizeof(struct list_member));
+ cur = ecalloc(1, sizeof(struct list_member));
cur->value = estrdup(*p);
cur->next = def_env_check;
def_env_check = cur;
/* Fill in the "env_keep" list. */
for (p = initial_keepenv_table; *p; p++) {
- cur = emalloc(sizeof(struct list_member));
+ cur = ecalloc(1, sizeof(struct list_member));
cur->value = estrdup(*p);
cur->next = def_env_keep;
def_env_keep = cur;
* In the event loop we pass input from user tty to master
* and pass output from master to stdout and IO plugin.
*/
- fdsr = (fd_set *)emalloc2(howmany(maxfd + 1, NFDBITS), sizeof(fd_mask));
- fdsw = (fd_set *)emalloc2(howmany(maxfd + 1, NFDBITS), sizeof(fd_mask));
+ fdsr = emalloc2(howmany(maxfd + 1, NFDBITS), sizeof(fd_mask));
+ fdsw = emalloc2(howmany(maxfd + 1, NFDBITS), sizeof(fd_mask));
for (;;) {
- zero_bytes(fdsw, howmany(maxfd + 1, NFDBITS) * sizeof(fd_mask));
- zero_bytes(fdsr, howmany(maxfd + 1, NFDBITS) * sizeof(fd_mask));
+ memset(fdsw, 0, howmany(maxfd + 1, NFDBITS) * sizeof(fd_mask));
+ memset(fdsr, 0, howmany(maxfd + 1, NFDBITS) * sizeof(fd_mask));
FD_SET(signal_pipe[0], fdsr);
FD_SET(sv[0], fdsr);
{
struct sigforward *sigfwd;
- sigfwd = emalloc(sizeof(*sigfwd));
+ sigfwd = ecalloc(1, sizeof(*sigfwd));
sigfwd->prev = sigfwd;
- sigfwd->next = NULL;
+ /* sigfwd->next = NULL; */
sigfwd->signo = signo;
tq_append(&sigfwd_list, sigfwd);
}
{
struct io_buffer *iob;
- iob = emalloc(sizeof(*iob));
- zero_bytes(iob, sizeof(*iob));
+ iob = ecalloc(1, sizeof(*iob));
iob->rfd = rfd;
iob->wfd = wfd;
iob->action = action;
/* Wait for errno on pipe, signal on backchannel or for SIGCHLD */
maxfd = MAX(MAX(errpipe[0], signal_pipe[0]), backchannel);
- fdsr = (fd_set *)emalloc2(howmany(maxfd + 1, NFDBITS), sizeof(fd_mask));
- zero_bytes(fdsr, howmany(maxfd + 1, NFDBITS) * sizeof(fd_mask));
+ fdsr = ecalloc(howmany(maxfd + 1, NFDBITS), sizeof(fd_mask));
zero_bytes(&cstat, sizeof(cstat));
tv.tv_sec = 0;
tv.tv_usec = 0;
if (maxfd == -1)
return;
- fdsr = (fd_set *)emalloc2(howmany(maxfd + 1, NFDBITS), sizeof(fd_mask));
- fdsw = (fd_set *)emalloc2(howmany(maxfd + 1, NFDBITS), sizeof(fd_mask));
+ fdsr = emalloc2(howmany(maxfd + 1, NFDBITS), sizeof(fd_mask));
+ fdsw = emalloc2(howmany(maxfd + 1, NFDBITS), sizeof(fd_mask));
for (;;) {
- zero_bytes(fdsw, howmany(maxfd + 1, NFDBITS) * sizeof(fd_mask));
- zero_bytes(fdsr, howmany(maxfd + 1, NFDBITS) * sizeof(fd_mask));
+ memset(fdsw, 0, howmany(maxfd + 1, NFDBITS) * sizeof(fd_mask));
+ memset(fdsr, 0, howmany(maxfd + 1, NFDBITS) * sizeof(fd_mask));
nwriters = 0;
for (iob = iobufs; iob; iob = iob->next) {
static struct ldap_result *
sudo_ldap_result_alloc()
{
- struct ldap_result *result;
-
- result = emalloc(sizeof(*result));
- result->searches = NULL;
- result->nentries = 0;
- result->entries = NULL;
- result->allocated_entries = 0;
- result->user_matches = FALSE;
- result->host_matches = FALSE;
- return result;
+ return ecalloc(1, sizeof(struct ldap_result));
}
/*
{
struct ldap_search_list *s, *news;
- news = emalloc(sizeof(struct ldap_search_list));
- news->next = NULL;
+ news = ecalloc(1, sizeof(struct ldap_search_list));
news->ldap = ldap;
news->searchresult = searchresult;
+ /* news->next = NULL; */
/* Add entry to the end of the chain (XXX - tailq instead?). */
if (lres->searches) {
return -1;
/* Create a handle container. */
- handle = emalloc(sizeof(struct sudo_ldap_handle));
+ handle = ecalloc(1, sizeof(struct sudo_ldap_handle));
handle->ld = ld;
- handle->result = NULL;
- handle->username = NULL;
- handle->groups = NULL;
+ /* handle->result = NULL; */
+ /* handle->username = NULL; *
+ /* handle->groups = NULL; *
nss->handle = handle;
return 0;
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;
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);
/* Resolve the path and return. */
rval = FOUND;
- user_stat = emalloc(sizeof(struct stat));
+ user_stat = ecalloc(1, sizeof(struct stat));
if (sudo_mode & (MODE_RUN | MODE_EDIT | MODE_CHECK)) {
if (ISSET(sudo_mode, MODE_RUN | MODE_CHECK)) {
if (def_secure_path && !user_is_exempt())
extern char *get_timestr __P((time_t, int));
extern int term_raw __P((int, int));
extern int term_restore __P((int, int));
-extern void zero_bytes __P((volatile void *, size_t));
RETSIGTYPE cleanup __P((int));
static int list_sessions __P((int, char **, const char *, const char *, const char *));
fclose(lfile);
fflush(stdout);
- zero_bytes(&sa, sizeof(sa));
+ memset(&sa, 0, sizeof(sa));
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_RESETHAND;
sa.sa_handler = cleanup;
if (!term_raw(STDIN_FILENO, 1))
error(1, "cannot set tty to raw mode");
}
- fdsw = (fd_set *)emalloc2(howmany(STDOUT_FILENO + 1, NFDBITS),
- sizeof(fd_mask));
+ fdsw = ecalloc(howmany(STDOUT_FILENO + 1, NFDBITS), sizeof(fd_mask));
/*
* Timing file consists of line of the format: "%f %d\n"
}
/* Allocate new search node */
- newsn = emalloc(sizeof(*newsn));
- newsn->next = NULL;
+ newsn = ecalloc(1, sizeof(*newsn));
newsn->type = type;
newsn->or = or;
newsn->negated = not;
+ /* newsn->next = NULL; */
if (type == ST_EXPR) {
av += parse_expr(&newsn->u.expr, av + 1);
} else {
char ch;
ssize_t n;
- fdsr = (fd_set *)emalloc2(howmany(ttyfd + 1, NFDBITS), sizeof(fd_mask));
+ fdsr = ecalloc(howmany(ttyfd + 1, NFDBITS), sizeof(fd_mask));
for (;;) {
FD_SET(ttyfd, fdsr);
break;
}
if (entry == NULL) {
- entry = emalloc(sizeof(*entry));
+ entry = ecalloc(1, sizeof(*entry));
entry->path = estrdup(path);
- entry->modified = 0;
+ /* entry->modified = 0; */
entry->prev = entry;
- entry->next = NULL;
+ /* entry->next = NULL; */
entry->fd = open(entry->path, open_flags, SUDOERS_MODE);
- entry->tpath = NULL;
+ /* entry->tpath = NULL; */
entry->doedit = doedit;
if (entry->fd == -1) {
warning("%s", entry->path);