Merge pull request #5079 from mitake/auth-fix

auth: remove index out of range in role grant
This commit is contained in:
Xiang Li
2016-04-14 08:07:18 -07:00

View File

@@ -279,7 +279,7 @@ func (as *authStore) RoleGrant(r *pb.AuthRoleGrantRequest) (*pb.AuthRoleGrantRes
return bytes.Compare(role.KeyPermission[i].Key, []byte(r.Perm.Key)) >= 0
})
if bytes.Equal(role.KeyPermission[idx].Key, r.Perm.Key) {
if idx < len(role.KeyPermission) && bytes.Equal(role.KeyPermission[idx].Key, r.Perm.Key) {
// update existing permission
role.KeyPermission[idx].PermType = r.Perm.PermType
} else {