summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2011-10-21 11:06:14 +0200
committerGünther Deschner <gd@samba.org>2011-10-21 11:07:25 +0200
commit81435bf26bf1081eeff0f1a06f40478c87e6dcb4 (patch)
tree15aeddf09097a0ab1f5e8c4793cd92f551c41295
parent23fea38debb7e4362511b4002a6b2c5e125c36f7 (diff)
downloadsamba-81435bf26bf1081eeff0f1a06f40478c87e6dcb4.tar.gz
samba-81435bf26bf1081eeff0f1a06f40478c87e6dcb4.tar.bz2
samba-81435bf26bf1081eeff0f1a06f40478c87e6dcb4.zip
s3-netapi: use NetApiBufferAllocate() for returned buffer in getdc calls.
Guenther
-rw-r--r--source3/lib/netapi/getdc.c32
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;