]> granicus.if.org Git - sudo/commitdiff
Use ecalloc() when allocating structs.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 19 Mar 2012 15:24:24 +0000 (11:24 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 19 Mar 2012 15:24:24 +0000 (11:24 -0400)
15 files changed:
common/sudo_conf.c
plugins/sudoers/alias.c
plugins/sudoers/defaults.c
plugins/sudoers/env.c
plugins/sudoers/gram.c
plugins/sudoers/gram.y
plugins/sudoers/interfaces.c
plugins/sudoers/ldap.c
plugins/sudoers/sudoers.c
plugins/sudoers/sudoreplay.c
plugins/sudoers/visudo.c
src/exec.c
src/exec_pty.c
src/hooks.c
src/load_plugins.c

index bf34254bce558e78955951138ca7019c83a4c162..3b7a0cc4e2108dfb51a83a5115a0706a911743ee 100644 (file)
@@ -242,12 +242,12 @@ set_plugin(const char *entry)
        pathlen = strlen(path);
     }
 
-    info = emalloc(sizeof(*info));
+    info = ecalloc(1, sizeof(*info));
     info->symbol_name = estrndup(name, namelen);
     info->path = estrndup(path, pathlen);
     info->options = options;
     info->prev = info;
-    info->next = NULL;
+    /* info->next = NULL; */
     tq_append(&sudo_conf_data.plugins, info);
 
     return true;
@@ -350,21 +350,21 @@ sudo_conf_read(void)
 done:
     if (tq_empty(&sudo_conf_data.plugins)) {
        /* Default policy plugin */
-       info = emalloc(sizeof(*info));
+       info = ecalloc(1, sizeof(*info));
        info->symbol_name = "sudoers_policy";
        info->path = SUDOERS_PLUGIN;
-       info->options = NULL;
+       /* info->options = NULL; */
        info->prev = info;
-       info->next = NULL;
+       /* info->next = NULL; */
        tq_append(&sudo_conf_data.plugins, info);
 
        /* Default I/O plugin */
-       info = emalloc(sizeof(*info));
+       info = ecalloc(1, sizeof(*info));
        info->symbol_name = "sudoers_io";
        info->path = SUDOERS_PLUGIN;
-       info->options = NULL;
+       /* info->options = NULL; */
        info->prev = info;
-       info->next = NULL;
+       /* info->next = NULL; */
        tq_append(&sudo_conf_data.plugins, info);
     }
 }
index aaba72881d809c065f43866f7e7a09e33dc8759f..eb95039f2ed5058b50645ecf8db77fddb39d0c54 100644 (file)
@@ -116,10 +116,10 @@ alias_add(char *name, int type, struct member *members)
     struct alias *a;
     debug_decl(alias_add, SUDO_DEBUG_ALIAS)
 
-    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);
index 5046ec2e70ebfefebdf826af4813b0ec8ff69498..6cab7e44e1a36bdb7dfcce66fc5bff826486d044 100644 (file)
@@ -790,10 +790,8 @@ list_op(char *val, size_t len, struct sudo_defs_types *def, enum list_ops op)
 
     /* Add new node to the head of the list. */
     if (op == add) {
-       cur = emalloc(sizeof(struct list_member));
-       cur->value = emalloc(len + 1);
-       (void) memcpy(cur->value, val, len);
-       cur->value[len] = '\0';
+       cur = ecalloc(1, sizeof(struct list_member));
+       cur->value = estrndup(val, len);
        cur->next = def->sd_un.list;
        def->sd_un.list = cur;
     }
index 3d2af7ffcc9d7b9a112f92d4ed7cc648870c1c88..de3fcba0dfbf1ad899c7a01ac7a947a7d8982cde 100644 (file)
@@ -986,7 +986,7 @@ init_envtables(void)
 
     /* 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;
@@ -994,7 +994,7 @@ init_envtables(void)
 
     /* 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;
@@ -1002,7 +1002,7 @@ init_envtables(void)
 
     /* 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;
index 6d5771b0c257bcd99156a81dc36ae0c930f9c9e4..62d6086b8a0fa347ff299456120cd0deaff9857b 100644 (file)
@@ -645,14 +645,14 @@ new_default(char *var, char *val, int op)
     struct defaults *d;
     debug_decl(new_default, SUDO_DEBUG_PARSER)
 
-    d = emalloc(sizeof(struct defaults));
+    d = ecalloc(1, sizeof(struct defaults));
     d->var = var;
     d->val = val;
     tq_init(&d->binding);
-    d->type = 0;
+    /* d->type = 0; */
     d->op = op;
     d->prev = d;
-    d->next = NULL;
+    /* d->next = NULL; */
 
     debug_return_ptr(d);
 }
@@ -663,11 +663,11 @@ new_member(char *name, int type)
     struct member *m;
     debug_decl(new_member, SUDO_DEBUG_PARSER)
 
-    m = emalloc(sizeof(struct member));
+    m = ecalloc(1, sizeof(struct member));
     m->name = name;
     m->type = type;
     m->prev = m;
-    m->next = NULL;
+    /* m->next = NULL; */
 
     debug_return_ptr(m);
 }
@@ -712,11 +712,11 @@ add_userspec(struct member *members, struct privilege *privs)
     struct userspec *u;
     debug_decl(add_userspec, SUDO_DEBUG_PARSER)
 
-    u = emalloc(sizeof(*u));
+    u = ecalloc(1, sizeof(*u));
     list2tq(&u->users, members);
     list2tq(&u->privileges, privs);
     u->prev = u;
-    u->next = NULL;
+    /* u->next = NULL; */
     tq_append(&userspecs, u);
 
     debug_return;
@@ -1155,11 +1155,11 @@ break;
 case 26:
 #line 269 "gram.y"
 {
-                           struct privilege *p = emalloc(sizeof(*p));
+                           struct privilege *p = ecalloc(1, sizeof(*p));
                            list2tq(&p->hostlist, yyvsp[-2].member);
                            list2tq(&p->cmndlist, yyvsp[0].cmndspec);
                            p->prev = p;
-                           p->next = NULL;
+                           /* p->next = NULL; */
                            yyval.privilege = p;
                        }
 break;
@@ -1243,7 +1243,7 @@ break;
 case 36:
 #line 339 "gram.y"
 {
-                           struct cmndspec *cs = emalloc(sizeof(*cs));
+                           struct cmndspec *cs = ecalloc(1, sizeof(*cs));
                            if (yyvsp[-3].runas != NULL) {
                                list2tq(&cs->runasuserlist, yyvsp[-3].runas->runasusers);
                                list2tq(&cs->runasgrouplist, yyvsp[-3].runas->runasgroups);
@@ -1343,15 +1343,15 @@ break;
 case 48:
 #line 415 "gram.y"
 {
-                           yyval.runas = emalloc(sizeof(struct runascontainer));
+                           yyval.runas = ecalloc(1, sizeof(struct runascontainer));
                            yyval.runas->runasusers = yyvsp[0].member;
-                           yyval.runas->runasgroups = NULL;
+                           /* $$->runasgroups = NULL; */
                        }
 break;
 case 49:
 #line 420 "gram.y"
 {
-                           yyval.runas = emalloc(sizeof(struct runascontainer));
+                           yyval.runas = ecalloc(1, sizeof(struct runascontainer));
                            yyval.runas->runasusers = yyvsp[-2].member;
                            yyval.runas->runasgroups = yyvsp[0].member;
                        }
@@ -1359,8 +1359,8 @@ break;
 case 50:
 #line 425 "gram.y"
 {
-                           yyval.runas = emalloc(sizeof(struct runascontainer));
-                           yyval.runas->runasusers = NULL;
+                           yyval.runas = ecalloc(1, sizeof(struct runascontainer));
+                           /* $$->runasusers = NULL; */
                            yyval.runas->runasgroups = yyvsp[0].member;
                        }
 break;
@@ -1446,7 +1446,7 @@ break;
 case 64:
 #line 474 "gram.y"
 {
-                           struct sudo_command *c = emalloc(sizeof(*c));
+                           struct sudo_command *c = ecalloc(1, sizeof(*c));
                            c->cmnd = yyvsp[0].command.cmnd;
                            c->args = yyvsp[0].command.args;
                            yyval.member = new_member((char *)c, COMMAND);
index c35571cf04bc1bf8bbafefe16db49af9066fd6c8..0315f243751caa4e62f1996677cf5d4db7cc18c9 100644 (file)
@@ -267,11 +267,11 @@ privileges        :       privilege
                ;
 
 privilege      :       hostlist '=' cmndspeclist {
-                           struct privilege *p = emalloc(sizeof(*p));
+                           struct privilege *p = ecalloc(1, sizeof(*p));
                            list2tq(&p->hostlist, $1);
                            list2tq(&p->cmndlist, $3);
                            p->prev = p;
-                           p->next = NULL;
+                           /* p->next = NULL; */
                            $$ = p;
                        }
                ;
@@ -337,7 +337,7 @@ cmndspeclist        :       cmndspec
                ;
 
 cmndspec       :       runasspec selinux cmndtag opcmnd {
-                           struct cmndspec *cs = emalloc(sizeof(*cs));
+                           struct cmndspec *cs = ecalloc(1, sizeof(*cs));
                            if ($1 != NULL) {
                                list2tq(&cs->runasuserlist, $1->runasusers);
                                list2tq(&cs->runasgrouplist, $1->runasgroups);
@@ -413,18 +413,18 @@ runasspec :       /* empty */ {
                ;
 
 runaslist      :       userlist {
-                           $$ = emalloc(sizeof(struct runascontainer));
+                           $$ = ecalloc(1, sizeof(struct runascontainer));
                            $$->runasusers = $1;
-                           $$->runasgroups = NULL;
+                           /* $$->runasgroups = NULL; */
                        }
                |       userlist ':' grouplist {
-                           $$ = emalloc(sizeof(struct runascontainer));
+                           $$ = ecalloc(1, sizeof(struct runascontainer));
                            $$->runasusers = $1;
                            $$->runasgroups = $3;
                        }
                |       ':' grouplist {
-                           $$ = emalloc(sizeof(struct runascontainer));
-                           $$->runasusers = NULL;
+                           $$ = ecalloc(1, sizeof(struct runascontainer));
+                           /* $$->runasusers = NULL; */
                            $$->runasgroups = $2;
                        }
                ;
@@ -472,7 +472,7 @@ cmnd                :       ALL {
                            $$ = new_member($1, ALIAS);
                        }
                |       COMMAND {
-                           struct sudo_command *c = emalloc(sizeof(*c));
+                           struct sudo_command *c = ecalloc(1, sizeof(*c));
                            c->cmnd = $1.cmnd;
                            c->args = $1.args;
                            $$ = new_member((char *)c, COMMAND);
@@ -614,14 +614,14 @@ new_default(char *var, char *val, int op)
     struct defaults *d;
     debug_decl(new_default, SUDO_DEBUG_PARSER)
 
-    d = emalloc(sizeof(struct defaults));
+    d = ecalloc(1, sizeof(struct defaults));
     d->var = var;
     d->val = val;
     tq_init(&d->binding);
-    d->type = 0;
+    /* d->type = 0; */
     d->op = op;
     d->prev = d;
-    d->next = NULL;
+    /* d->next = NULL; */
 
     debug_return_ptr(d);
 }
@@ -632,11 +632,11 @@ new_member(char *name, int type)
     struct member *m;
     debug_decl(new_member, SUDO_DEBUG_PARSER)
 
-    m = emalloc(sizeof(struct member));
+    m = ecalloc(1, sizeof(struct member));
     m->name = name;
     m->type = type;
     m->prev = m;
-    m->next = NULL;
+    /* m->next = NULL; */
 
     debug_return_ptr(m);
 }
@@ -681,11 +681,11 @@ add_userspec(struct member *members, struct privilege *privs)
     struct userspec *u;
     debug_decl(add_userspec, SUDO_DEBUG_PARSER)
 
-    u = emalloc(sizeof(*u));
+    u = ecalloc(1, sizeof(*u));
     list2tq(&u->users, members);
     list2tq(&u->privileges, privs);
     u->prev = u;
-    u->next = NULL;
+    /* u->next = NULL; */
     tq_append(&userspecs, u);
 
     debug_return;
index 04d5b6704fb8cda7e8ba976313ca47844bb1d80e..624882e2735383260ce36b9e920c2a537030caa2 100644 (file)
@@ -71,7 +71,7 @@ set_interfaces(const char *ai)
        *mask++ = '\0';
 
        /* Parse addr and store in list. */
-       ifp = emalloc(sizeof(*ifp));
+       ifp = ecalloc(1, sizeof(*ifp));
        if (strchr(addr, ':')) {
            /* IPv6 */
 #ifdef HAVE_STRUCT_IN6_ADDR
index 126a4858a05d2174a3c2e7610b9eafe834939921..e4bfe021df868c7848ed86b9abfe2be3e739ee0b 100644 (file)
@@ -1984,14 +1984,7 @@ sudo_ldap_result_alloc(void)
     struct ldap_result *result;
     debug_decl(sudo_ldap_result_alloc, SUDO_DEBUG_LDAP)
 
-    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;
-    debug_return_ptr(result);
+    debug_return_ptr(ecalloc(1, sizeof(*result)));
 }
 
 /*
@@ -2030,10 +2023,10 @@ sudo_ldap_result_add_search(struct ldap_result *lres, LDAP *ldap,
     struct ldap_search_list *s, *news;
     debug_decl(sudo_ldap_result_add_search, SUDO_DEBUG_LDAP)
 
-    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) {
@@ -2200,11 +2193,11 @@ sudo_ldap_open(struct sudo_nss *nss)
        debug_return_int(-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->grlist = NULL;
+    /* handle->result = NULL; */
+    /* handle->username = NULL; */
+    /* handle->grlist = NULL; */
     nss->handle = handle;
 
     debug_return_int(0);
index 7b35d2863e6493bd54109c2fa61f7509ee25e419..26bb926ed8952105e1e070df38be8fa559fada3a 100644 (file)
@@ -884,7 +884,7 @@ set_cmnd(void)
 
     /* Resolve the path and return. */
     rval = FOUND;
-    user_stat = emalloc(sizeof(struct stat));
+    user_stat = ecalloc(1, sizeof(struct stat));
 
     /* Default value for cmnd, overridden below. */
     if (user_cmnd == NULL)
index df83a50e03155572ede6bf26631e35986b6ed6b8..db98e6cc2080bb3e717970b49f7bbc40842dfcb8 100644 (file)
@@ -200,7 +200,6 @@ extern time_t get_date(char *);
 extern char *get_timestr(time_t, int);
 extern int term_raw(int, int);
 extern int term_restore(int, int);
-extern void zero_bytes(volatile void *, size_t);
 void cleanup(int);
 
 static int list_sessions(int, char **, const char *, const char *, const char *);
@@ -368,7 +367,7 @@ main(int argc, char *argv[])
     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;
@@ -391,8 +390,7 @@ main(int argc, char *argv[])
        if (!term_raw(STDIN_FILENO, 1))
            error(1, _("unable to 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"
@@ -590,11 +588,11 @@ parse_expr(struct search_node **headp, char *argv[])
        }
 
        /* 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 {
@@ -871,8 +869,7 @@ check_input(int ttyfd, double *speed)
     ssize_t n;
     debug_decl(check_input, SUDO_DEBUG_UTIL)
 
-    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);
        tv.tv_sec = 0;
index 72cd5bfd921035043e96918475d041ef59cabac4..5aadabb096a90dfd50f7d7107f90b90ef3d8e0ad 100644 (file)
@@ -880,13 +880,13 @@ open_sudoers(const char *path, bool doedit, bool *keepopen)
            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);
index 80e87177ac5b9a20addeadcbe6cdb6a1b8ba35c5..b485006491eb04d37021da9bb3d1134279c3e1e9 100644 (file)
@@ -320,11 +320,11 @@ sudo_execute(struct command_details *details, struct command_status *cstat)
      * 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);
@@ -582,9 +582,9 @@ schedule_signal(int signo)
 
     sudo_debug_printf(SUDO_DEBUG_DIAG, "forwarding signal %d to child", signo);
 
-    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);
 
index 07ce0708cb4da0d37cc6b561c13b882e6dc972fc..c78e793e536c1e5ca9855ff4dde12565014c41cf 100644 (file)
@@ -405,7 +405,7 @@ io_buf_new(int rfd, int wfd, bool (*action)(const char *, unsigned int),
     struct io_buffer *iob;
     debug_decl(io_buf_new, SUDO_DEBUG_EXEC);
 
-    iob = emalloc(sizeof(*iob));
+    iob = ecalloc(1, sizeof(*iob));
     zero_bytes(iob, sizeof(*iob));
     iob->rfd = rfd;
     iob->wfd = wfd;
@@ -989,9 +989,8 @@ exec_monitor(struct command_details *details, int backchannel)
 
     /* 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));
-    zero_bytes(&cstat, sizeof(cstat));
+    fdsr = ecalloc(howmany(maxfd + 1, NFDBITS), sizeof(fd_mask));
+    memset(&cstat, 0, sizeof(cstat));
     tv.tv_sec = 0;
     tv.tv_usec = 0;
     for (;;) {
@@ -1102,11 +1101,11 @@ flush_output(void)
     if (maxfd == -1)
        debug_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) {
index 5e8a395edc6ec2be0321ab4d7227f77f2b395cdf..b2daaa95f9735b12a559d7aa196dc224c293672f 100644 (file)
@@ -171,7 +171,7 @@ register_hook_internal(struct sudo_hook_list **head,
     struct sudo_hook_list *hook;
     debug_decl(register_hook_internal, SUDO_DEBUG_HOOKS)
 
-    hook = emalloc(sizeof(*hook));
+    hook = ecalloc(1, sizeof(*hook));
     hook->u.generic_fn = hook_fn;
     hook->closure = closure;
     hook->next = *head;
index 45d63a1296f6773b8929a4881af2c417f1ef16c7..767f8ee70097d8566032e3fca22f148a28f3dadc 100644 (file)
@@ -134,9 +134,9 @@ sudo_load_plugins(struct plugin_container *policy_plugin,
            policy_plugin->options = info->options;
            policy_plugin->u.generic = plugin;
        } else if (plugin->type == SUDO_IO_PLUGIN) {
-           container = emalloc(sizeof(*container));
+           container = ecalloc(1, sizeof(*container));
            container->prev = container;
-           container->next = NULL;
+           /* container->next = NULL; */
            container->handle = handle;
            container->name = info->symbol_name;
            container->options = info->options;