s3:wb_lookupsids: add some paranoia checks to wb_lookupsids_recv()
authorStefan Metzmacher <metze@samba.org>
Thu, 16 Jun 2011 16:25:15 +0000 (18:25 +0200)
committerStefan Metzmacher <metze@samba.org>
Thu, 16 Jun 2011 17:50:16 +0000 (19:50 +0200)
This hopefully catches future bugs.

metze

Autobuild-User: Stefan Metzmacher <metze@samba.org>
Autobuild-Date: Thu Jun 16 19:50:16 CEST 2011 on sn-devel-104

source3/winbindd/wb_lookupsids.c

index 8f431ab4fc6d5992ac3e6a72a709dabeee13fb81..92eee039ed9a076cab57bf63f3f31cefa440a71f 100644 (file)
@@ -639,6 +639,24 @@ NTSTATUS wb_lookupsids_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
        if (tevent_req_is_nterror(req, &status)) {
                return status;
        }
+
+       /*
+        * The returned names need to match the given sids,
+        * if not we have a bug in the code!
+        *
+        */
+       SMB_ASSERT(state->res_names->count == state->num_sids);
+
+       /*
+        * Not strictly needed, but it might make debugging in the callers
+        * easier in future, if the talloc_array_length() returns the
+        * expected result...
+        */
+       state->res_domains->domains = talloc_realloc(state->res_domains,
+                                                    state->res_domains->domains,
+                                                    struct lsa_DomainInfo,
+                                                    state->res_domains->count);
+
        *domains = talloc_move(mem_ctx, &state->res_domains);
        *names = talloc_move(mem_ctx, &state->res_names);
        return NT_STATUS_OK;