From: Jeremy Allison Date: Wed, 11 Jan 2017 19:52:44 +0000 (-0800) Subject: winbind: Fix CID 1398534 Dereference before null check X-Git-Tag: talloc-2.1.9~389 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e1874bbf26eaa162cd6a5f11d96c564a983c9893;p=thirdparty%2Fsamba.git winbind: Fix CID 1398534 Dereference before null check Make all query_user_list backends consistent. Signed-off-by: Jeremy Allison Reviewed-by: Andreas Schneider Autobuild-User(master): Andreas Schneider Autobuild-Date(master): Fri Jan 13 13:33:37 CET 2017 on sn-devel-144 --- diff --git a/source3/winbindd/winbindd_ads.c b/source3/winbindd/winbindd_ads.c index b14f21e3644..077c6ec7b7c 100644 --- a/source3/winbindd/winbindd_ads.c +++ b/source3/winbindd/winbindd_ads.c @@ -293,14 +293,12 @@ static NTSTATUS query_user_list(struct winbindd_domain *domain, ADS_STRUCT *ads = NULL; const char *attrs[] = { "sAMAccountType", "objectSid", NULL }; int count; - uint32_t *rids; + uint32_t *rids = NULL; ADS_STATUS rc; LDAPMessage *res = NULL; LDAPMessage *msg = NULL; NTSTATUS status = NT_STATUS_UNSUCCESSFUL; - *prids = NULL; - DEBUG(3,("ads: query_user_list\n")); if ( !winbindd_can_contact_domain( domain ) ) { @@ -375,7 +373,9 @@ static NTSTATUS query_user_list(struct winbindd_domain *domain, } rids = talloc_realloc(mem_ctx, rids, uint32_t, count); - *prids = rids; + if (prids != NULL) { + *prids = rids; + } status = NT_STATUS_OK; diff --git a/source3/winbindd/winbindd_samr.c b/source3/winbindd/winbindd_samr.c index 224f1058348..1a73fc4fcc6 100644 --- a/source3/winbindd/winbindd_samr.c +++ b/source3/winbindd/winbindd_samr.c @@ -169,15 +169,13 @@ static NTSTATUS sam_query_user_list(struct winbindd_domain *domain, { struct rpc_pipe_client *samr_pipe = NULL; struct policy_handle dom_pol = { 0 }; - uint32_t *rids; + uint32_t *rids = NULL; TALLOC_CTX *tmp_ctx; NTSTATUS status, result; struct dcerpc_binding_handle *b = NULL; DEBUG(3,("samr_query_user_list\n")); - *prids = NULL; - tmp_ctx = talloc_stackframe(); if (tmp_ctx == NULL) { return NT_STATUS_NO_MEMORY; @@ -199,7 +197,7 @@ static NTSTATUS sam_query_user_list(struct winbindd_domain *domain, goto done; } - if (prids) { + if (prids != NULL) { *prids = talloc_move(mem_ctx, &rids); }