diff options
author | Michal Zidek <mzidek@redhat.com> | 2013-08-14 18:22:06 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2013-09-03 16:23:33 +0200 |
commit | 17db46b22e1c2d1575af3c715d92c1f936dd005b (patch) | |
tree | 248c9c75bb6e0d51dab10fe9321ac800cdef4d35 /src/sss_client/nss_mc_group.c | |
parent | d24e56b78c13d6e4f65786edf2d45ac9a7735f33 (diff) | |
download | sssd-17db46b22e1c2d1575af3c715d92c1f936dd005b.tar.gz sssd-17db46b22e1c2d1575af3c715d92c1f936dd005b.tar.xz sssd-17db46b22e1c2d1575af3c715d92c1f936dd005b.zip |
mmap_cache: Off by one error.
Removes off by one error when using macro MC_SIZE_TO_SLOTS
and adds new macro MC_SLOT_WITHIN_BOUNDS.
Diffstat (limited to 'src/sss_client/nss_mc_group.c')
-rw-r--r-- | src/sss_client/nss_mc_group.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/sss_client/nss_mc_group.c b/src/sss_client/nss_mc_group.c index 871857b07..40fbd072f 100644 --- a/src/sss_client/nss_mc_group.c +++ b/src/sss_client/nss_mc_group.c @@ -122,7 +122,7 @@ errno_t sss_nss_mc_getgrnam(const char *name, size_t name_len, /* If slot is not within the bounds of mmaped region and * it's value is not MC_INVALID_VAL, then the cache is * probbably corrupted. */ - while (slot < MC_SIZE_TO_SLOTS(gr_mc_ctx.dt_size)) { + while (MC_SLOT_WITHIN_BOUNDS(slot, gr_mc_ctx.dt_size)) { ret = sss_nss_mc_get_record(&gr_mc_ctx, slot, &rec); if (ret) { goto done; @@ -156,7 +156,7 @@ errno_t sss_nss_mc_getgrnam(const char *name, size_t name_len, slot = rec->next; } - if (slot >= MC_SIZE_TO_SLOTS(gr_mc_ctx.dt_size)) { + if (!MC_SLOT_WITHIN_BOUNDS(slot, gr_mc_ctx.dt_size)) { ret = ENOENT; goto done; } @@ -197,7 +197,7 @@ errno_t sss_nss_mc_getgrgid(gid_t gid, /* If slot is not within the bounds of mmaped region and * it's value is not MC_INVALID_VAL, then the cache is * probbably corrupted. */ - while (slot < MC_SIZE_TO_SLOTS(gr_mc_ctx.dt_size)) { + while (MC_SLOT_WITHIN_BOUNDS(slot, gr_mc_ctx.dt_size)) { ret = sss_nss_mc_get_record(&gr_mc_ctx, slot, &rec); if (ret) { goto done; @@ -218,7 +218,7 @@ errno_t sss_nss_mc_getgrgid(gid_t gid, slot = rec->next; } - if (slot >= MC_SIZE_TO_SLOTS(gr_mc_ctx.dt_size)) { + if (!MC_SLOT_WITHIN_BOUNDS(slot, gr_mc_ctx.dt_size)) { ret = ENOENT; goto done; } |