Blame SOURCES/0065-IFP-ListByName-Don-t-crash-when-no-results-are-found.patch

bb7cd1
From c9268488cd24fe8e13580d6c4ea2fa237faededa Mon Sep 17 00:00:00 2001
bb7cd1
From: Jakub Hrozek <jhrozek@redhat.com>
bb7cd1
Date: Tue, 28 Mar 2017 14:07:29 +0200
bb7cd1
Subject: [PATCH 65/72] IFP: ListByName: Don't crash when no results are found
bb7cd1
MIME-Version: 1.0
bb7cd1
Content-Type: text/plain; charset=UTF-8
bb7cd1
Content-Transfer-Encoding: 8bit
bb7cd1
bb7cd1
If no results were found using the List command, the results variable
bb7cd1
was undefined which resulted in a crash.
bb7cd1
bb7cd1
Instead, only copy the results of the cache_req lookup returns EOK and
bb7cd1
we can presume that the results are valid.
bb7cd1
bb7cd1
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
bb7cd1
Reviewed-by: Sumit Bose <sbose@redhat.com>
bb7cd1
---
bb7cd1
 src/responder/ifp/ifp_users.c | 16 +++++++++-------
bb7cd1
 1 file changed, 9 insertions(+), 7 deletions(-)
bb7cd1
bb7cd1
diff --git a/src/responder/ifp/ifp_users.c b/src/responder/ifp/ifp_users.c
bb7cd1
index ce9557f94351b730ee46f3cbce31613cb5901942..188194f2ab356d0e67b0f26b003f3a9ce48e6acd 100644
bb7cd1
--- a/src/responder/ifp/ifp_users.c
bb7cd1
+++ b/src/responder/ifp/ifp_users.c
bb7cd1
@@ -801,7 +801,7 @@ static void ifp_users_list_by_name_done(struct tevent_req *req)
bb7cd1
     DBusError *error;
bb7cd1
     struct ifp_list_ctx *list_ctx;
bb7cd1
     struct sbus_request *sbus_req;
bb7cd1
-    struct cache_req_result *result;
bb7cd1
+    struct cache_req_result *result = NULL;
bb7cd1
     errno_t ret;
bb7cd1
 
bb7cd1
     list_ctx = tevent_req_callback_data(req, struct ifp_list_ctx);
bb7cd1
@@ -816,12 +816,14 @@ static void ifp_users_list_by_name_done(struct tevent_req *req)
bb7cd1
         return;
bb7cd1
     }
bb7cd1
 
bb7cd1
-    ret = ifp_users_list_copy(list_ctx, result->ldb_result);
bb7cd1
-    if (ret != EOK) {
bb7cd1
-        error = sbus_error_new(sbus_req, SBUS_ERROR_INTERNAL,
bb7cd1
-                               "Failed to copy domain result");
bb7cd1
-        sbus_request_fail_and_finish(sbus_req, error);
bb7cd1
-        return;
bb7cd1
+    if (ret == EOK) {
bb7cd1
+        ret = ifp_users_list_copy(list_ctx, result->ldb_result);
bb7cd1
+        if (ret != EOK) {
bb7cd1
+            error = sbus_error_new(sbus_req, SBUS_ERROR_INTERNAL,
bb7cd1
+                                "Failed to copy domain result");
bb7cd1
+            sbus_request_fail_and_finish(sbus_req, error);
bb7cd1
+            return;
bb7cd1
+        }
bb7cd1
     }
bb7cd1
 
bb7cd1
     list_ctx->dom = get_next_domain(list_ctx->dom, SSS_GND_DESCEND);
bb7cd1
-- 
bb7cd1
2.9.3
bb7cd1