Skip to content

Commit

Permalink
sunrpc: Use gid_valid to test for gid != INVALID_GID
Browse files Browse the repository at this point in the history
In auth unix there are a couple of places INVALID_GID is used a
sentinel to mark the end of uc_gids array.  Use gid_valid
as a type safe way to verify we have not hit the end of
valid data in the array.

Cc: "J. Bruce Fields" <bfields@fieldses.org>
Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
  • Loading branch information
Eric W. Biederman committed Feb 13, 2013
1 parent cdba321 commit e572fc7
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions net/sunrpc/auth_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ unx_match(struct auth_cred *acred, struct rpc_cred *rcred, int flags)
for (i = 0; i < groups ; i++)
if (!gid_eq(cred->uc_gids[i], GROUP_AT(acred->group_info, i)))
return 0;
if (groups < NFS_NGROUPS &&
cred->uc_gids[groups] != INVALID_GID)
if (groups < NFS_NGROUPS && gid_valid(cred->uc_gids[groups]))
return 0;
return 1;
}
Expand Down Expand Up @@ -161,7 +160,7 @@ unx_marshal(struct rpc_task *task, __be32 *p)
*p++ = htonl((u32) cred->uc_uid);
*p++ = htonl((u32) cred->uc_gid);
hold = p++;
for (i = 0; i < 16 && cred->uc_gids[i] != INVALID_GID; i++)
for (i = 0; i < 16 && gid_valid(cred->uc_gids[i]); i++)
*p++ = htonl((u32) cred->uc_gids[i]);
*hold = htonl(p - hold - 1); /* gid array length */
*base = htonl((p - base - 1) << 2); /* cred length */
Expand Down

0 comments on commit e572fc7

Please sign in to comment.