summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLukas Slebodnik <lslebodn@redhat.com>2013-09-05 09:26:43 +0200
committerJakub Hrozek <jhrozek@redhat.com>2013-09-09 13:57:27 +0200
commit27ea6c34e9d8a914b0aeebe9ca98eb65dea404d0 (patch)
tree3a350d8903a39756ba92a5f19a204f2174d8f600 /src
parent35da30eb7f97968aabcbd34d4e198e44470ad3dd (diff)
downloadsssd-27ea6c34e9d8a914b0aeebe9ca98eb65dea404d0.tar.gz
sssd-27ea6c34e9d8a914b0aeebe9ca98eb65dea404d0.tar.bz2
sssd-27ea6c34e9d8a914b0aeebe9ca98eb65dea404d0.zip
mmap_cache: Do not remove record from chain twice
It is not very likely, that record will have the same hash1 and hash2, but it is possible. In this situation, it does not make sense to remove record twice. Function sss_mc_rm_rec_from_chain was not robust and sssd_nss could crash in this situation. It was only possible if record was alone in chain. Resolves: https://fedorahosted.org/sssd/ticket/2049
Diffstat (limited to 'src')
-rw-r--r--src/responder/nss/nsssrv_mmap_cache.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/responder/nss/nsssrv_mmap_cache.c b/src/responder/nss/nsssrv_mmap_cache.c
index 84570ac2..a22bbd59 100644
--- a/src/responder/nss/nsssrv_mmap_cache.c
+++ b/src/responder/nss/nsssrv_mmap_cache.c
@@ -243,6 +243,12 @@ static void sss_mc_rm_rec_from_chain(struct sss_mc_ctx *mcc,
}
slot = mcc->hash_table[hash];
+ if (slot == MC_INVALID_VAL) {
+ /* record has already been removed. It may happen if rec->hash1 and
+ * rec->has2 are the same. (It is not very likely).
+ */
+ return;
+ }
cur = MC_SLOT_TO_PTR(mcc->data_table, slot, struct sss_mc_rec);
if (cur == rec) {
/* rec->next can refer to record without matching hashes.