[SSSD] [PATCH] memberof: check for empty arrays to avoid segfaults
Sumit Bose
sbose at redhat.com
Wed Oct 29 14:26:19 UTC 2014
Hi,
I'm quite confident that this patch can fix
https://fedorahosted.org/sssd/ticket/2430 . Unfortunately I have no idea
how to reproduce a condition which would trigger this issue, so I'm on
completely sure. Any ideas for reproducers are welcome.
bye,
Sumit
-------------- next part --------------
From 81d4019d792d4d80e4ae7ecc444229c0fcfdb1e9 Mon Sep 17 00:00:00 2001
From: Sumit Bose <sbose at redhat.com>
Date: Wed, 29 Oct 2014 15:20:12 +0100
Subject: [PATCH] memberof: check for empty arrays to avoid segfaults
The arrays with members to add or delete may be empty, i.e. have 0
entries. In this case further processing should be skipped to avoid
segfaults later on.
Fixes (hopefully) https://fedorahosted.org/sssd/ticket/2430
---
src/ldb_modules/memberof.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/ldb_modules/memberof.c b/src/ldb_modules/memberof.c
index ceeba0e..995c382 100644
--- a/src/ldb_modules/memberof.c
+++ b/src/ldb_modules/memberof.c
@@ -3654,7 +3654,7 @@ static int mbof_mod_add(struct mbof_mod_ctx *mod_ctx,
}
}
- if (ael != NULL) {
+ if (ael != NULL && ael->num > 0) {
/* Add itself to the list of the parents to also get the memberuid */
parents->dns = talloc_realloc(parents, parents->dns,
struct ldb_dn *, parents->num + 1);
@@ -3724,7 +3724,7 @@ static int mbof_mod_delete(struct mbof_mod_ctx *mod_ctx,
}
/* prepare del sets */
- if (del != NULL) {
+ if (del != NULL && del->num > 0) {
for (i = 0; i < del->num; i++) {
ret = mbof_append_delop(first, del->dns[i]);
if (ret != LDB_SUCCESS) {
--
1.8.3.1
More information about the sssd-devel
mailing list