diff options
Diffstat (limited to 'source3/lib/netapi')
-rw-r--r-- | source3/lib/netapi/getdc.c | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/source3/lib/netapi/getdc.c b/source3/lib/netapi/getdc.c index e753deacb0..3b26d46db4 100644 --- a/source3/lib/netapi/getdc.c +++ b/source3/lib/netapi/getdc.c @@ -43,6 +43,8 @@ WERROR NetGetDCName_r(struct libnetapi_ctx *ctx, NTSTATUS status; WERROR werr; struct dcerpc_binding_handle *b; + const char *dcname; + void *buffer; werr = libnetapi_get_binding_handle(ctx, r->in.server_name, &ndr_table_netlogon.syntax_id, @@ -54,12 +56,24 @@ WERROR NetGetDCName_r(struct libnetapi_ctx *ctx, status = dcerpc_netr_GetDcName(b, talloc_tos(), r->in.server_name, r->in.domain_name, - (const char **)r->out.buffer, + &dcname, &werr); if (!NT_STATUS_IS_OK(status)) { werr = ntstatus_to_werror(status); + goto done; + } + + if (!W_ERROR_IS_OK(werr)) { + goto done; + } + + if (NetApiBufferAllocate(strlen_m_term(dcname), &buffer)) { + werr = WERR_NOMEM; + goto done; } + memcpy(buffer, dcname, strlen_m_term(dcname)); + *r->out.buffer = buffer; done: return werr; @@ -83,6 +97,8 @@ WERROR NetGetAnyDCName_r(struct libnetapi_ctx *ctx, NTSTATUS status; WERROR werr; struct dcerpc_binding_handle *b; + const char *dcname; + void *buffer; werr = libnetapi_get_binding_handle(ctx, r->in.server_name, &ndr_table_netlogon.syntax_id, @@ -94,12 +110,24 @@ WERROR NetGetAnyDCName_r(struct libnetapi_ctx *ctx, status = dcerpc_netr_GetAnyDCName(b, talloc_tos(), r->in.server_name, r->in.domain_name, - (const char **)r->out.buffer, + &dcname, &werr); if (!NT_STATUS_IS_OK(status)) { werr = ntstatus_to_werror(status); goto done; } + + if (!W_ERROR_IS_OK(werr)) { + goto done; + } + + if (NetApiBufferAllocate(strlen_m_term(dcname), &buffer)) { + werr = WERR_NOMEM; + goto done; + } + memcpy(buffer, dcname, strlen_m_term(dcname)); + *r->out.buffer = buffer; + done: return werr; |