summaryrefslogtreecommitdiffstats
path: root/src/sss_client/nss_mc_passwd.c
diff options
context:
space:
mode:
authorMichal Zidek <mzidek@redhat.com>2013-08-14 18:22:06 +0200
committerJakub Hrozek <jhrozek@redhat.com>2013-08-30 14:31:09 +0200
commit488f449bc57ca147432f8906d04ad111cd498b0d (patch)
treedc7cd8cb982cd3bf8c2820521c0082af3b0bf91e /src/sss_client/nss_mc_passwd.c
parent9460c08f23402850d942941200bc15a3fa530ef6 (diff)
downloadsssd-488f449bc57ca147432f8906d04ad111cd498b0d.tar.gz
sssd-488f449bc57ca147432f8906d04ad111cd498b0d.tar.xz
sssd-488f449bc57ca147432f8906d04ad111cd498b0d.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.c8
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 e412fb404..353cd1146 100644
--- a/src/sss_client/nss_mc_passwd.c
+++ b/src/sss_client/nss_mc_passwd.c
@@ -123,7 +123,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;
@@ -158,7 +158,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;
}
@@ -199,7 +199,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;
@@ -220,7 +220,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;
}