diff options
author | Sumit Bose <sbose@redhat.com> | 2014-10-29 15:20:12 +0100 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2015-06-19 14:09:45 +0200 |
commit | 46e74b8f554b69949b95c6ec1772c3f301eee2ae (patch) | |
tree | 3ded089761551021dca9d6612eb3e99a9055f344 | |
parent | c6500f433ee8ee7e2543a84a480cf4ad7f18532a (diff) | |
download | sssd-46e74b8f554b69949b95c6ec1772c3f301eee2ae.tar.gz sssd-46e74b8f554b69949b95c6ec1772c3f301eee2ae.tar.xz sssd-46e74b8f554b69949b95c6ec1772c3f301eee2ae.zip |
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
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
(cherry picked from commit a1bd8bc666df7fa696523ec8ec1dfe3d79780588)
-rw-r--r-- | src/ldb_modules/memberof.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/ldb_modules/memberof.c b/src/ldb_modules/memberof.c index c26a13bb9..c49be5d5f 100644 --- a/src/ldb_modules/memberof.c +++ b/src/ldb_modules/memberof.c @@ -3655,7 +3655,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); @@ -3725,7 +3725,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) { |