dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

Blame SOURCES/0129-CACHE_REQ-Avoid-using-of-uninitialized-value.patch

bb7cd1
From 6a1da829eaa1eee3e854f0cadc0b6effff776ab4 Mon Sep 17 00:00:00 2001
bb7cd1
From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= <fidencio@redhat.com>
bb7cd1
Date: Mon, 15 May 2017 11:54:00 +0200
bb7cd1
Subject: [PATCH 1/2] CACHE_REQ: Avoid using of uninitialized value
bb7cd1
MIME-Version: 1.0
bb7cd1
Content-Type: text/plain; charset=UTF-8
bb7cd1
Content-Transfer-Encoding: 8bit
bb7cd1
bb7cd1
Commit 4ef0b19a introduced the following warning, as "req" may be used
bb7cd1
without being initialized:
bb7cd1
src/responder/common/cache_req/cache_req_search.c:
bb7cd1
     In function 'cache_req_search_done':
bb7cd1
src/responder/common/cache_req/cache_req_search.c:467:9:
bb7cd1
     error: 'req' may be used uninitialized in this function
bb7cd1
     [-Werror=maybe-uninitialized]
bb7cd1
         tevent_req_error(req, ret);
bb7cd1
         ^
bb7cd1
src/responder/common/cache_req/cache_req_search.c:424:24:
bb7cd1
     note: 'req' was declared here
bb7cd1
     struct tevent_req *req;
bb7cd1
                        ^
bb7cd1
cc1: all warnings being treated as errors
bb7cd1
bb7cd1
In order to fix the issue above, let's just allocate tmp_ctx after "req"
bb7cd1
is already set.
bb7cd1
bb7cd1
Related:
bb7cd1
https://pagure.io/SSSD/sssd/issue/3362
bb7cd1
bb7cd1
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
bb7cd1
Co-Author: Lukáš Slebodník <lslebodn@redhat.com>
bb7cd1
Reviewed-by: Sumit Bose <sbose@redhat.com>
bb7cd1
---
bb7cd1
 src/responder/common/cache_req/cache_req_search.c | 12 ++++++------
bb7cd1
 1 file changed, 6 insertions(+), 6 deletions(-)
bb7cd1
bb7cd1
diff --git a/src/responder/common/cache_req/cache_req_search.c b/src/responder/common/cache_req/cache_req_search.c
bb7cd1
index 793dbc5042ae329b2cade5d1eb5a6d41102e264f..70448a7639bc9f98d380b8edce9d130adfa0ceb2 100644
bb7cd1
--- a/src/responder/common/cache_req/cache_req_search.c
bb7cd1
+++ b/src/responder/common/cache_req/cache_req_search.c
bb7cd1
@@ -425,18 +425,18 @@ static void cache_req_search_done(struct tevent_req *subreq)
bb7cd1
     struct ldb_result *result = NULL;
bb7cd1
     errno_t ret;
bb7cd1
 
bb7cd1
-    tmp_ctx = talloc_new(NULL);
bb7cd1
-    if (tmp_ctx == NULL) {
bb7cd1
-        ret = ENOMEM;
bb7cd1
-        goto done;
bb7cd1
-    }
bb7cd1
-
bb7cd1
     req = tevent_req_callback_data(subreq, struct tevent_req);
bb7cd1
     state = tevent_req_data(req, struct cache_req_search_state);
bb7cd1
 
bb7cd1
     state->dp_success = state->cr->plugin->dp_recv_fn(subreq, state->cr);
bb7cd1
     talloc_zfree(subreq);
bb7cd1
 
bb7cd1
+    tmp_ctx = talloc_new(NULL);
bb7cd1
+    if (tmp_ctx == NULL) {
bb7cd1
+        ret = ENOMEM;
bb7cd1
+        goto done;
bb7cd1
+    }
bb7cd1
+
bb7cd1
     /* Get result from cache again. */
bb7cd1
     ret = cache_req_search_cache(tmp_ctx, state->cr, &result);
bb7cd1
     if (ret != EOK) {
bb7cd1
-- 
bb7cd1
2.9.3
bb7cd1