From: Todd C. Miller Date: Thu, 2 Aug 2007 02:08:39 +0000 (+0000) Subject: Fix off by one in group matching. X-Git-Tag: SUDO_1_7_0~452 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4fea71625b4c29c388070aa84f83a6e036a5274f;p=sudo Fix off by one in group matching. --- diff --git a/match.c b/match.c index ea52824af..ded638144 100644 --- a/match.c +++ b/match.c @@ -514,7 +514,7 @@ usergr_matches(group, user, pw) { struct group *grp; char **cur; - int n; + int i; /* make sure we have a valid usergroup, sudo style */ if (*group++ != '%') @@ -536,8 +536,8 @@ usergr_matches(group, user, pw) * supplementary group vector, check it first. */ if (strcmp(user, list_pw ? list_pw->pw_name : user_name) == 0) { - for (n = user_ngroups; n != 0; n--) - if (grp->gr_gid == user_groups[n]) + for (i = 0; i < user_ngroups; i++) + if (grp->gr_gid == user_groups[i]) return(TRUE); } if (grp->gr_mem != NULL) {