From c58c458dc919104958454f33e6887791e5965a33 Mon Sep 17 00:00:00 2001 From: Michal Zidek Date: Wed, 14 Aug 2013 18:22:06 +0200 Subject: 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. --- src/responder/nss/nsssrv_mmap_cache.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/responder') diff --git a/src/responder/nss/nsssrv_mmap_cache.c b/src/responder/nss/nsssrv_mmap_cache.c index 2458cd419..e74c75c16 100644 --- a/src/responder/nss/nsssrv_mmap_cache.c +++ b/src/responder/nss/nsssrv_mmap_cache.c @@ -368,12 +368,12 @@ static struct sss_mc_rec *sss_mc_find_record(struct sss_mc_ctx *mcc, hash = sss_mc_hash(mcc, key->str, key->len); slot = mcc->hash_table[hash]; - if (slot > MC_SIZE_TO_SLOTS(mcc->dt_size)) { + if (!MC_SLOT_WITHIN_BOUNDS(slot, mcc->dt_size)) { return NULL; } while (slot != MC_INVALID_VAL) { - if (slot > MC_SIZE_TO_SLOTS(mcc->dt_size)) { + if (!MC_SLOT_WITHIN_BOUNDS(slot, mcc->dt_size)) { DEBUG(SSSDBG_FATAL_FAILURE, ("Corrupted fastcache. Slot number too big.\n")); sss_mmap_cache_reset(mcc); @@ -602,13 +602,13 @@ errno_t sss_mmap_cache_pw_invalidate_uid(struct sss_mc_ctx *mcc, uid_t uid) hash = sss_mc_hash(mcc, uidstr, strlen(uidstr) + 1); slot = mcc->hash_table[hash]; - if (slot > MC_SIZE_TO_SLOTS(mcc->dt_size)) { + if (!MC_SLOT_WITHIN_BOUNDS(slot, mcc->dt_size)) { ret = ENOENT; goto done; } while (slot != MC_INVALID_VAL) { - if (slot > MC_SIZE_TO_SLOTS(mcc->dt_size)) { + if (!MC_SLOT_WITHIN_BOUNDS(slot, mcc->dt_size)) { DEBUG(SSSDBG_FATAL_FAILURE, ("Corrupted fastcache.\n")); sss_mmap_cache_reset(mcc); ret = ENOENT; @@ -745,13 +745,13 @@ errno_t sss_mmap_cache_gr_invalidate_gid(struct sss_mc_ctx *mcc, gid_t gid) hash = sss_mc_hash(mcc, gidstr, strlen(gidstr) + 1); slot = mcc->hash_table[hash]; - if (slot > MC_SIZE_TO_SLOTS(mcc->dt_size)) { + if (!MC_SLOT_WITHIN_BOUNDS(slot, mcc->dt_size)) { ret = ENOENT; goto done; } while (slot != MC_INVALID_VAL) { - if (slot > MC_SIZE_TO_SLOTS(mcc->dt_size)) { + if (!MC_SLOT_WITHIN_BOUNDS(slot, mcc->dt_size)) { DEBUG(SSSDBG_FATAL_FAILURE, ("Corrupted fastcache.\n")); sss_mmap_cache_reset(mcc); ret = ENOENT; -- cgit