|
|
32a074 |
From 9ace3a7899e6b3753ef428088303e0a646db4096 Mon Sep 17 00:00:00 2001
|
|
|
32a074 |
From: Alexey Tikhonov <atikhono@redhat.com>
|
|
|
32a074 |
Date: Sun, 22 Nov 2020 17:44:07 +0100
|
|
|
32a074 |
Subject: [PATCH] SYSDB: merge_res_sysdb_attrs() fixed to avoid NULL ptr in
|
|
|
32a074 |
msgs[]
|
|
|
32a074 |
MIME-Version: 1.0
|
|
|
32a074 |
Content-Type: text/plain; charset=UTF-8
|
|
|
32a074 |
Content-Transfer-Encoding: 8bit
|
|
|
32a074 |
|
|
|
32a074 |
This helps to avoid sssd_be segfaults at be_refresh_get_values_ex() due to NULL
|
|
|
32a074 |
ptrs in results of sysdb_search_with_ts_attr()
|
|
|
32a074 |
|
|
|
32a074 |
Resolves: https://github.com/SSSD/sssd/issues/5412
|
|
|
32a074 |
|
|
|
32a074 |
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
|
|
|
32a074 |
(cherry picked from commit ff24d1538af88f83d0a3cc2817952cf70e7ca580)
|
|
|
32a074 |
---
|
|
|
32a074 |
src/db/sysdb_search.c | 11 +++++++----
|
|
|
32a074 |
1 file changed, 7 insertions(+), 4 deletions(-)
|
|
|
32a074 |
|
|
|
32a074 |
diff --git a/src/db/sysdb_search.c b/src/db/sysdb_search.c
|
|
|
32a074 |
index 6c89b4c98..7939944ba 100644
|
|
|
32a074 |
--- a/src/db/sysdb_search.c
|
|
|
32a074 |
+++ b/src/db/sysdb_search.c
|
|
|
32a074 |
@@ -221,6 +221,7 @@ static errno_t merge_res_sysdb_attrs(TALLOC_CTX *mem_ctx,
|
|
|
32a074 |
const char *attrs[])
|
|
|
32a074 |
{
|
|
|
32a074 |
errno_t ret;
|
|
|
32a074 |
+ size_t ts_cache_res_count = 0;
|
|
|
32a074 |
struct ldb_result *ts_cache_res = NULL;
|
|
|
32a074 |
|
|
|
32a074 |
if (ts_res == NULL || ctx->ldb_ts == NULL) {
|
|
|
32a074 |
@@ -231,7 +232,6 @@ static errno_t merge_res_sysdb_attrs(TALLOC_CTX *mem_ctx,
|
|
|
32a074 |
if (ts_cache_res == NULL) {
|
|
|
32a074 |
return ENOMEM;
|
|
|
32a074 |
}
|
|
|
32a074 |
- ts_cache_res->count = ts_res->count;
|
|
|
32a074 |
ts_cache_res->msgs = talloc_zero_array(ts_cache_res,
|
|
|
32a074 |
struct ldb_message *,
|
|
|
32a074 |
ts_res->count);
|
|
|
32a074 |
@@ -244,15 +244,18 @@ static errno_t merge_res_sysdb_attrs(TALLOC_CTX *mem_ctx,
|
|
|
32a074 |
ret = merge_msg_sysdb_attrs(ts_cache_res->msgs,
|
|
|
32a074 |
ctx,
|
|
|
32a074 |
ts_res->msgs[c],
|
|
|
32a074 |
- &ts_cache_res->msgs[c], attrs);
|
|
|
32a074 |
- if (ret != EOK) {
|
|
|
32a074 |
+ &ts_cache_res->msgs[ts_cache_res_count],
|
|
|
32a074 |
+ attrs);
|
|
|
32a074 |
+ if ((ret != EOK) || (ts_cache_res->msgs[ts_cache_res_count] == NULL)) {
|
|
|
32a074 |
DEBUG(SSSDBG_MINOR_FAILURE,
|
|
|
32a074 |
"Cannot merge sysdb cache values for %s\n",
|
|
|
32a074 |
ldb_dn_get_linearized(ts_res->msgs[c]->dn));
|
|
|
32a074 |
- /* non-fatal, we just get only the non-timestamp attrs */
|
|
|
32a074 |
+ /* non-fatal, just skip */
|
|
|
32a074 |
continue;
|
|
|
32a074 |
}
|
|
|
32a074 |
+ ts_cache_res_count += 1;
|
|
|
32a074 |
}
|
|
|
32a074 |
+ ts_cache_res->count = ts_cache_res_count;
|
|
|
32a074 |
|
|
|
32a074 |
*_ts_cache_res = ts_cache_res;
|
|
|
32a074 |
return EOK;
|
|
|
32a074 |
--
|
|
|
32a074 |
2.21.3
|
|
|
32a074 |
|