diff options
author | Michal Zidek <mzidek@redhat.com> | 2013-08-14 18:22:06 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2013-08-19 20:57:00 +0200 |
commit | c58c458dc919104958454f33e6887791e5965a33 (patch) | |
tree | 2ca2070a49a5202de70cd25e97bc630db7340653 /src/sss_client/nss_mc_passwd.c | |
parent | 87fb9c039db9acdc1f00de35d3373e8e5788d432 (diff) | |
download | sssd-c58c458dc919104958454f33e6887791e5965a33.tar.gz sssd-c58c458dc919104958454f33e6887791e5965a33.tar.xz sssd-c58c458dc919104958454f33e6887791e5965a33.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_passwd.c')
-rw-r--r-- | src/sss_client/nss_mc_passwd.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/sss_client/nss_mc_passwd.c b/src/sss_client/nss_mc_passwd.c index 7aca4a04b..a0a8d87f7 100644 --- a/src/sss_client/nss_mc_passwd.c +++ b/src/sss_client/nss_mc_passwd.c @@ -122,7 +122,7 @@ errno_t sss_nss_mc_getpwnam(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(pw_mc_ctx.dt_size)) { + while (MC_SLOT_WITHIN_BOUNDS(slot, pw_mc_ctx.dt_size)) { ret = sss_nss_mc_get_record(&pw_mc_ctx, slot, &rec); if (ret) { goto done; @@ -157,7 +157,7 @@ errno_t sss_nss_mc_getpwnam(const char *name, size_t name_len, slot = rec->next; } - if (slot >= MC_SIZE_TO_SLOTS(pw_mc_ctx.dt_size)) { + if (!MC_SLOT_WITHIN_BOUNDS(slot, pw_mc_ctx.dt_size)) { ret = ENOENT; goto done; } @@ -198,7 +198,7 @@ errno_t sss_nss_mc_getpwuid(uid_t uid, /* 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(pw_mc_ctx.dt_size)) { + while (MC_SLOT_WITHIN_BOUNDS(slot, pw_mc_ctx.dt_size)) { ret = sss_nss_mc_get_record(&pw_mc_ctx, slot, &rec); if (ret) { goto done; @@ -219,7 +219,7 @@ errno_t sss_nss_mc_getpwuid(uid_t uid, slot = rec->next; } - if (slot >= MC_SIZE_TO_SLOTS(pw_mc_ctx.dt_size)) { + if (!MC_SLOT_WITHIN_BOUNDS(slot, pw_mc_ctx.dt_size)) { ret = ENOENT; goto done; } |