s3: Fix bug 8904 -- wbinfo --lookup-sids "" crashes winbind
authorVolker Lendecke <vl@samba.org>
Sat, 28 Apr 2012 17:51:46 +0000 (19:51 +0200)
committerVolker Lendecke <vl@samba.org>
Sat, 28 Apr 2012 20:04:14 +0000 (22:04 +0200)
Much of the code further down and up the call chain expects the
structures wb_lookupsids returns to be allocated. Do that despite
we have nothing to look up.

source3/winbindd/wb_lookupsids.c

index e896860e0138c46fb990bcb8fab1370dea94f9c8..ae815ce067244bee7048d56c609c0e8457ef4ba6 100644 (file)
@@ -123,11 +123,6 @@ struct tevent_req *wb_lookupsids_send(TALLOC_CTX *mem_ctx,
        state->sids = sids;
        state->num_sids = num_sids;
 
-       if (num_sids == 0) {
-               tevent_req_done(req);
-               return tevent_req_post(req, ev);
-       }
-
        state->single_sids = talloc_array(state, uint32_t, num_sids);
        if (tevent_req_nomem(state->single_sids, req)) {
                return tevent_req_post(req, ev);
@@ -153,6 +148,11 @@ struct tevent_req *wb_lookupsids_send(TALLOC_CTX *mem_ctx,
                return tevent_req_post(req, ev);
        }
 
+       if (num_sids == 0) {
+               tevent_req_done(req);
+               return tevent_req_post(req, ev);
+       }
+
        for (i=0; i<num_sids; i++) {
                struct wb_lookupsids_domain *d;