diff --git a/plugins/sudoers/editor.c b/plugins/sudoers/editor.c index 48d06a71b..a0cd63d43 100644 --- a/plugins/sudoers/editor.c +++ b/plugins/sudoers/editor.c @@ -123,7 +123,7 @@ resolve_editor(const char *ed, size_t edlen, int nfiles, char **files, int *argc_out, char ***argv_out, char * const *allowlist) { char **nargv = NULL, *editor = NULL, *editor_path = NULL; - const char *cp, *ep, *tmp; + const char *tmp, *cp, *ep = NULL; const char *edend = ed + edlen; struct stat user_editor_sb; int nargc; diff --git a/plugins/sudoers/fmtsudoers.c b/plugins/sudoers/fmtsudoers.c index e14bac054..07961a485 100644 --- a/plugins/sudoers/fmtsudoers.c +++ b/plugins/sudoers/fmtsudoers.c @@ -177,7 +177,7 @@ sudoers_defaults_list_to_tags(struct defaults_list *defs, struct cmndtag *tags) struct defaults *d; debug_decl(sudoers_defaults_list_to_tags, SUDOERS_DEBUG_UTIL); - TAGS_INIT(*tags); + TAGS_INIT(tags); if (defs != NULL) { TAILQ_FOREACH(d, defs, entries) { if (!sudoers_defaults_to_tags(d->var, d->val, d->op, tags)) { diff --git a/plugins/sudoers/gram.c b/plugins/sudoers/gram.c index abd299bc4..661b2167b 100644 --- a/plugins/sudoers/gram.c +++ b/plugins/sudoers/gram.c @@ -2565,7 +2565,7 @@ yyreduce: case 92: /* cmndtag: %empty */ #line 785 "gram.y" { - TAGS_INIT((yyval.tag)); + TAGS_INIT(&(yyval.tag)); } #line 2565 "gram.c" break; diff --git a/plugins/sudoers/gram.y b/plugins/sudoers/gram.y index b9439f37b..0957a1fe5 100644 --- a/plugins/sudoers/gram.y +++ b/plugins/sudoers/gram.y @@ -783,7 +783,7 @@ options : /* empty */ { ; cmndtag : /* empty */ { - TAGS_INIT($$); + TAGS_INIT(&$$); } | cmndtag NOPASSWD { $$.nopasswd = true; diff --git a/plugins/sudoers/ldap_util.c b/plugins/sudoers/ldap_util.c index 5d7a4b1a4..080c77e7b 100644 --- a/plugins/sudoers/ldap_util.c +++ b/plugins/sudoers/ldap_util.c @@ -458,7 +458,7 @@ sudo_ldap_role_to_priv(const char *cn, void *hosts, void *runasusers, TAILQ_INSERT_TAIL(&priv->cmndlist, cmndspec, entries); /* Initialize cmndspec */ - TAGS_INIT(cmndspec->tags); + TAGS_INIT(&cmndspec->tags); cmndspec->notbefore = UNSPEC; cmndspec->notafter = UNSPEC; cmndspec->timeout = UNSPEC; diff --git a/plugins/sudoers/parse.h b/plugins/sudoers/parse.h index a3390bc26..711bf87e1 100644 --- a/plugins/sudoers/parse.h +++ b/plugins/sudoers/parse.h @@ -42,13 +42,13 @@ * Initialize all tags to UNSPEC. */ #define TAGS_INIT(t) do { \ - (t).follow = UNSPEC; \ - (t).log_input = UNSPEC; \ - (t).log_output = UNSPEC; \ - (t).noexec = UNSPEC; \ - (t).nopasswd = UNSPEC; \ - (t).send_mail = UNSPEC; \ - (t).setenv = UNSPEC; \ + (t)->follow = UNSPEC; \ + (t)->log_input = UNSPEC; \ + (t)->log_output = UNSPEC; \ + (t)->noexec = UNSPEC; \ + (t)->nopasswd = UNSPEC; \ + (t)->send_mail = UNSPEC; \ + (t)->setenv = UNSPEC; \ } while (0) /* diff --git a/plugins/sudoers/starttime.c b/plugins/sudoers/starttime.c index 8217a77b2..daee5fde1 100644 --- a/plugins/sudoers/starttime.c +++ b/plugins/sudoers/starttime.c @@ -98,7 +98,7 @@ get_starttime(pid_t pid, struct timespec *starttime) mib[3] = (int)pid; mib[4] = sizeof(*ki_proc); mib[5] = 1; - do { + for (;;) { struct sudo_kinfo_proc *kp; size += size / 10; @@ -108,7 +108,9 @@ get_starttime(pid_t pid, struct timespec *starttime) } ki_proc = kp; rc = sysctl(mib, sudo_kp_namelen, ki_proc, &size, NULL, 0); - } while (rc == -1 && errno == ENOMEM); + if (rc != -1 || errno != ENOMEM) + break; + } if (rc != -1) { #if defined(HAVE_KINFO_PROC_FREEBSD) /* FreeBSD and Dragonfly */ diff --git a/plugins/sudoers/tsgetgrpw.c b/plugins/sudoers/tsgetgrpw.c index 3e5d616bb..2b6d3cbf0 100644 --- a/plugins/sudoers/tsgetgrpw.c +++ b/plugins/sudoers/tsgetgrpw.c @@ -356,8 +356,7 @@ sudo_getgrouplist2_v1(const char *name, GETGROUPS_T basegid, GETGROUPS_T **groupsp, int *ngroupsp) { GETGROUPS_T *groups = *groupsp; - int grpsize = *ngroupsp; - int i, ngroups = 1; + int i, grpsize, ngroups = 1; int ret = -1; struct group *grp; @@ -372,7 +371,7 @@ sudo_getgrouplist2_v1(const char *name, GETGROUPS_T basegid, grpsize <<= 2; } else { /* Static group vector. */ - if (grpsize < 1) + if ((grpsize = *ngroupsp) < 1) return -1; } diff --git a/src/ttyname.c b/src/ttyname.c index 7a80ccc94..47e4ab13f 100644 --- a/src/ttyname.c +++ b/src/ttyname.c @@ -111,7 +111,7 @@ get_process_ttyname(char *name, size_t namelen) mib[3] = (int)getpid(); mib[4] = sizeof(*ki_proc); mib[5] = 1; - do { + for (;;) { struct sudo_kinfo_proc *kp; size += size / 10; @@ -121,7 +121,9 @@ get_process_ttyname(char *name, size_t namelen) } ki_proc = kp; rc = sysctl(mib, sudo_kp_namelen, ki_proc, &size, NULL, 0); - } while (rc == -1 && errno == ENOMEM); + if (rc != -1 || errno != ENOMEM) + break; + } errno = ENOENT; if (rc != -1) { if ((dev_t)ki_proc->sudo_kp_tdev != (dev_t)-1) {