URL: https://github.com/SSSD/sssd/pull/273
Author: fidencio
 Title: #273: CACHE_REQ_SEARCH: Avoid using of unitialized value
Action: synchronized

To pull the PR as Git branch:
git remote add ghsssd https://github.com/SSSD/sssd
git fetch ghsssd pull/273/head:pr273
git checkout pr273
From c28a42eba49829cf785ea7b3429c536747863a19 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= <[email protected]>
Date: Mon, 15 May 2017 11:54:00 +0200
Subject: [PATCH] CACHE_REQ_SEARCH: Avoid using of unitialized value
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Commit 4ef0b19a introduced the following warning, as "req" may be used
without being initialized:
src/responder/common/cache_req/cache_req_search.c:
     In function 'cache_req_search_done':
src/responder/common/cache_req/cache_req_search.c:467:9:
     error: 'req' may be used uninitialized in this function
     [-Werror=maybe-uninitialized]
         tevent_req_error(req, ret);
         ^
src/responder/common/cache_req/cache_req_search.c:424:24:
     note: 'req' was declared here
     struct tevent_req *req;
                        ^
cc1: all warnings being treated as errors

In order to fix the issue above, let's just allocate tmp_ctx after "req"
is already set.

This issue was caught by the internal coverity instance.

Related:
https://pagure.io/SSSD/sssd/issue/3362

Signed-off-by: Fabiano Fidêncio <[email protected]>
Co-Author: Lukáš Slebodník <[email protected]>
---
 src/responder/common/cache_req/cache_req_search.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/responder/common/cache_req/cache_req_search.c b/src/responder/common/cache_req/cache_req_search.c
index 793dbc5..70448a7 100644
--- a/src/responder/common/cache_req/cache_req_search.c
+++ b/src/responder/common/cache_req/cache_req_search.c
@@ -425,18 +425,18 @@ static void cache_req_search_done(struct tevent_req *subreq)
     struct ldb_result *result = NULL;
     errno_t ret;
 
-    tmp_ctx = talloc_new(NULL);
-    if (tmp_ctx == NULL) {
-        ret = ENOMEM;
-        goto done;
-    }
-
     req = tevent_req_callback_data(subreq, struct tevent_req);
     state = tevent_req_data(req, struct cache_req_search_state);
 
     state->dp_success = state->cr->plugin->dp_recv_fn(subreq, state->cr);
     talloc_zfree(subreq);
 
+    tmp_ctx = talloc_new(NULL);
+    if (tmp_ctx == NULL) {
+        ret = ENOMEM;
+        goto done;
+    }
+
     /* Get result from cache again. */
     ret = cache_req_search_cache(tmp_ctx, state->cr, &result);
     if (ret != EOK) {
_______________________________________________
sssd-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to