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

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