summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLukas Slebodnik <lslebodn@redhat.com>2013-08-19 07:24:46 +0200
committerJakub Hrozek <jhrozek@redhat.com>2013-08-28 16:47:41 +0200
commitb8d0374cd23db90fce203292ff547641f62e338a (patch)
tree949aae0fc7df5a9445739541b3870f7c09317755 /src
parent4662725ffef62b3b2502481438effa7c8fef9f80 (diff)
downloadsssd-b8d0374cd23db90fce203292ff547641f62e338a.tar.gz
sssd-b8d0374cd23db90fce203292ff547641f62e338a.tar.bz2
sssd-b8d0374cd23db90fce203292ff547641f62e338a.zip
mmap_cache: Use stricter check for hash keys.
ht_size is size of hash_table in bytes, but hash keys have type uint32_t
Diffstat (limited to 'src')
-rw-r--r--src/responder/nss/nsssrv_mmap_cache.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/responder/nss/nsssrv_mmap_cache.c b/src/responder/nss/nsssrv_mmap_cache.c
index 66afe6fd..84570ac2 100644
--- a/src/responder/nss/nsssrv_mmap_cache.c
+++ b/src/responder/nss/nsssrv_mmap_cache.c
@@ -177,7 +177,7 @@ static void sss_mc_add_rec_to_chain(struct sss_mc_ctx *mcc,
struct sss_mc_rec *cur;
uint32_t slot;
- if (hash > mcc->ht_size) {
+ if (hash > MC_HT_ELEMS(mcc->ht_size)) {
/* Invalid hash. This should never happen, but better
* return than trying to access out of bounds memory */
return;
@@ -234,9 +234,11 @@ static void sss_mc_rm_rec_from_chain(struct sss_mc_ctx *mcc,
struct sss_mc_rec *cur = NULL;
uint32_t slot;
- if (hash > mcc->ht_size) {
- /* Invalid hash. This should never happen, but better
- * return than trying to access out of bounds memory */
+ if (hash > MC_HT_ELEMS(mcc->ht_size)) {
+ /* It can happen if rec->hash1 and rec->hash2 was the same.
+ * or it is invalid hash. It is better to return
+ * than trying to access out of bounds memory
+ */
return;
}