diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2013-02-01 20:18:04 -0500 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2013-02-13 09:15:20 -0500 |
commit | e572fc739822ad779493b8a72bd27f2101fc3373 (patch) | |
tree | 0178825a3990b0b316e7ecd2830cdcfbc3451a5e /net | |
parent | cdba321e291f0fbf5abda4d88340292b858e3d4d (diff) |
sunrpc: Use gid_valid to test for gid != INVALID_GID
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>
Diffstat (limited to 'net')
-rw-r--r-- | net/sunrpc/auth_unix.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/net/sunrpc/auth_unix.c b/net/sunrpc/auth_unix.c index 55b6ca6fbbd3..c434fde2079b 100644 --- a/net/sunrpc/auth_unix.c +++ b/net/sunrpc/auth_unix.c | |||
@@ -131,8 +131,7 @@ unx_match(struct auth_cred *acred, struct rpc_cred *rcred, int flags) | |||
131 | for (i = 0; i < groups ; i++) | 131 | for (i = 0; i < groups ; i++) |
132 | if (!gid_eq(cred->uc_gids[i], GROUP_AT(acred->group_info, i))) | 132 | if (!gid_eq(cred->uc_gids[i], GROUP_AT(acred->group_info, i))) |
133 | return 0; | 133 | return 0; |
134 | if (groups < NFS_NGROUPS && | 134 | if (groups < NFS_NGROUPS && gid_valid(cred->uc_gids[groups])) |
135 | cred->uc_gids[groups] != INVALID_GID) | ||
136 | return 0; | 135 | return 0; |
137 | return 1; | 136 | return 1; |
138 | } | 137 | } |
@@ -161,7 +160,7 @@ unx_marshal(struct rpc_task *task, __be32 *p) | |||
161 | *p++ = htonl((u32) cred->uc_uid); | 160 | *p++ = htonl((u32) cred->uc_uid); |
162 | *p++ = htonl((u32) cred->uc_gid); | 161 | *p++ = htonl((u32) cred->uc_gid); |
163 | hold = p++; | 162 | hold = p++; |
164 | for (i = 0; i < 16 && cred->uc_gids[i] != INVALID_GID; i++) | 163 | for (i = 0; i < 16 && gid_valid(cred->uc_gids[i]); i++) |
165 | *p++ = htonl((u32) cred->uc_gids[i]); | 164 | *p++ = htonl((u32) cred->uc_gids[i]); |
166 | *hold = htonl(p - hold - 1); /* gid array length */ | 165 | *hold = htonl(p - hold - 1); /* gid array length */ |
167 | *base = htonl((p - base - 1) << 2); /* cred length */ | 166 | *base = htonl((p - base - 1) << 2); /* cred length */ |