summaryrefslogtreecommitdiff
path: root/source4/rpc_server/samr
diff options
context:
space:
mode:
authorMatthias Dieter Wallnöfer <mdw@samba.org>2010-06-11 23:57:39 +0200
committerMatthias Dieter Wallnöfer <mdw@samba.org>2010-06-12 16:45:47 +0200
commitcdecae6c03fd4ce49f3bcabfe5fccc1c9e7488b0 (patch)
tree4a5ffef1e91db85ce5ba0bb90c4734fd225311b0 /source4/rpc_server/samr
parent0171f714b4caf6ef67ea36729106b89e91706002 (diff)
downloadsamba-cdecae6c03fd4ce49f3bcabfe5fccc1c9e7488b0.tar.gz
samba-cdecae6c03fd4ce49f3bcabfe5fccc1c9e7488b0.tar.bz2
samba-cdecae6c03fd4ce49f3bcabfe5fccc1c9e7488b0.zip
s4:dcesrv_samr_QueryDomainInfo - allocate the "info" structure only when really needed
That means the allocation should move after the lookup (as it is on "QueryUserInfo"). Return "NT_STATUS_NO_SUCH_DOMAIN" on an invalid domain.
Diffstat (limited to 'source4/rpc_server/samr')
-rw-r--r--source4/rpc_server/samr/dcesrv_samr.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/source4/rpc_server/samr/dcesrv_samr.c b/source4/rpc_server/samr/dcesrv_samr.c
index 12249eb066..8e1b2b068e 100644
--- a/source4/rpc_server/samr/dcesrv_samr.c
+++ b/source4/rpc_server/samr/dcesrv_samr.c
@@ -732,11 +732,6 @@ static NTSTATUS dcesrv_samr_QueryDomainInfo(struct dcesrv_call_state *dce_call,
d_state = h->data;
- info = talloc(mem_ctx, union samr_DomainInfo);
- if (!info) {
- return NT_STATUS_NO_MEMORY;
- }
-
switch (r->in.level) {
case 1:
{
@@ -843,14 +838,21 @@ static NTSTATUS dcesrv_samr_QueryDomainInfo(struct dcesrv_call_state *dce_call,
int ret;
ret = gendb_search_dn(d_state->sam_ctx, mem_ctx,
d_state->domain_dn, &dom_msgs, attrs);
+ if (ret == 0) {
+ return NT_STATUS_NO_SUCH_DOMAIN;
+ }
if (ret != 1) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
}
- *r->out.info = info;
+ /* allocate the info structure */
+ info = talloc_zero(mem_ctx, union samr_DomainInfo);
+ if (info == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
- ZERO_STRUCTP(info);
+ *r->out.info = info;
switch (r->in.level) {
case 1: