From 5935ea9da149b10f6969d892a238564894f478f4 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 26 Sep 2006 19:37:37 +0000 Subject: [PATCH] r18929: * Clarify QueryValue IDL and regenerate code * Fix server _winreg_Query_Value() implementation so that usrmgr.exe starts now (This used to be commit 435d7bfc37f430c462fcb53bf3a82fcddc809771) --- source3/librpc/gen_ndr/cli_winreg.c | 10 +- source3/librpc/gen_ndr/cli_winreg.h | 2 +- source3/librpc/gen_ndr/ndr_winreg.c | 160 ++++++++++++++-------------- source3/librpc/gen_ndr/srv_winreg.c | 6 +- source3/librpc/gen_ndr/srv_winreg.h | 2 +- source3/librpc/gen_ndr/winreg.h | 12 +-- source3/librpc/idl/winreg.idl | 6 +- source3/rpc_server/srv_winreg_nt.c | 33 +++--- 8 files changed, 117 insertions(+), 114 deletions(-) diff --git a/source3/librpc/gen_ndr/cli_winreg.c b/source3/librpc/gen_ndr/cli_winreg.c index 5ef93d3a927..0890a8d6b7a 100644 --- a/source3/librpc/gen_ndr/cli_winreg.c +++ b/source3/librpc/gen_ndr/cli_winreg.c @@ -512,7 +512,7 @@ NTSTATUS rpccli_winreg_QueryInfoKey(struct rpc_pipe_client *cli, TALLOC_CTX *mem return werror_to_ntstatus(r.out.result); } -NTSTATUS rpccli_winreg_QueryValue(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct winreg_String value_name, enum winreg_Type *type, uint8_t *data, uint32_t *size, uint32_t *length) +NTSTATUS rpccli_winreg_QueryValue(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct winreg_String value_name, enum winreg_Type *type, uint8_t *data, uint32_t *data_size, uint32_t *value_length) { struct winreg_QueryValue r; NTSTATUS status; @@ -522,8 +522,8 @@ NTSTATUS rpccli_winreg_QueryValue(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c r.in.value_name = value_name; r.in.type = type; r.in.data = data; - r.in.size = size; - r.in.length = length; + r.in.data_size = data_size; + r.in.value_length = value_length; if (DEBUGLEVEL >= 10) NDR_PRINT_IN_DEBUG(winreg_QueryValue, &r); @@ -540,8 +540,8 @@ NTSTATUS rpccli_winreg_QueryValue(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c /* Return variables */ *type = *r.out.type; *data = *r.out.data; - *size = *r.out.size; - *length = *r.out.length; + *data_size = *r.out.data_size; + *value_length = *r.out.value_length; /* Return result */ return werror_to_ntstatus(r.out.result); diff --git a/source3/librpc/gen_ndr/cli_winreg.h b/source3/librpc/gen_ndr/cli_winreg.h index 041efd2b910..3fabf183156 100644 --- a/source3/librpc/gen_ndr/cli_winreg.h +++ b/source3/librpc/gen_ndr/cli_winreg.h @@ -18,7 +18,7 @@ NTSTATUS rpccli_winreg_LoadKey(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, NTSTATUS rpccli_winreg_NotifyChangeKeyValue(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *handle, uint8_t watch_subtree, uint32_t notify_filter, uint32_t unknown, struct winreg_String string1, struct winreg_String string2, uint32_t unknown2); NTSTATUS rpccli_winreg_OpenKey(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *parent_handle, struct winreg_String keyname, uint32_t unknown, uint32_t access_mask, struct policy_handle *handle); NTSTATUS rpccli_winreg_QueryInfoKey(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct winreg_String class_in, struct winreg_String *class_out, uint32_t *num_subkeys, uint32_t *max_subkeylen, uint32_t *max_subkeysize, uint32_t *num_values, uint32_t *max_valnamelen, uint32_t *max_valbufsize, uint32_t *secdescsize, NTTIME *last_changed_time); -NTSTATUS rpccli_winreg_QueryValue(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct winreg_String value_name, enum winreg_Type *type, uint8_t *data, uint32_t *size, uint32_t *length); +NTSTATUS rpccli_winreg_QueryValue(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct winreg_String value_name, enum winreg_Type *type, uint8_t *data, uint32_t *data_size, uint32_t *value_length); NTSTATUS rpccli_winreg_ReplaceKey(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx); NTSTATUS rpccli_winreg_RestoreKey(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx); NTSTATUS rpccli_winreg_SaveKey(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx); diff --git a/source3/librpc/gen_ndr/ndr_winreg.c b/source3/librpc/gen_ndr/ndr_winreg.c index ca007bb449c..998e4e08618 100644 --- a/source3/librpc/gen_ndr/ndr_winreg.c +++ b/source3/librpc/gen_ndr/ndr_winreg.c @@ -2282,18 +2282,18 @@ NTSTATUS ndr_push_winreg_QueryValue(struct ndr_push *ndr, int flags, const struc } NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.data)); if (r->in.data) { - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->in.size)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->in.data_size)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->in.length)); - NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->in.data, *r->in.length)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->in.value_length)); + NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->in.data, *r->in.value_length)); } - NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.size)); - if (r->in.size) { - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->in.size)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.data_size)); + if (r->in.data_size) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->in.data_size)); } - NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.length)); - if (r->in.length) { - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->in.length)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->in.value_length)); + if (r->in.value_length) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->in.value_length)); } } if (flags & NDR_OUT) { @@ -2303,18 +2303,18 @@ NTSTATUS ndr_push_winreg_QueryValue(struct ndr_push *ndr, int flags, const struc } NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.data)); if (r->out.data) { - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.size)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.data_size)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.length)); - NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->out.data, *r->out.length)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.value_length)); + NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->out.data, *r->out.value_length)); } - NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.size)); - if (r->out.size) { - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.size)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.data_size)); + if (r->out.data_size) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.data_size)); } - NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.length)); - if (r->out.length) { - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.length)); + NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.value_length)); + if (r->out.value_length) { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, *r->out.value_length)); } NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result)); } @@ -2325,13 +2325,13 @@ NTSTATUS ndr_pull_winreg_QueryValue(struct ndr_pull *ndr, int flags, struct winr { uint32_t _ptr_type; uint32_t _ptr_data; - uint32_t _ptr_size; - uint32_t _ptr_length; + uint32_t _ptr_data_size; + uint32_t _ptr_value_length; TALLOC_CTX *_mem_save_handle_0; TALLOC_CTX *_mem_save_type_0; TALLOC_CTX *_mem_save_data_0; - TALLOC_CTX *_mem_save_size_0; - TALLOC_CTX *_mem_save_length_0; + TALLOC_CTX *_mem_save_data_size_0; + TALLOC_CTX *_mem_save_value_length_0; if (flags & NDR_IN) { ZERO_STRUCT(r->out); @@ -2373,37 +2373,37 @@ NTSTATUS ndr_pull_winreg_QueryValue(struct ndr_pull *ndr, int flags, struct winr NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->in.data, ndr_get_array_length(ndr, &r->in.data))); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_0, 0); } - NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_size)); - if (_ptr_size) { - NDR_PULL_ALLOC(ndr, r->in.size); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_data_size)); + if (_ptr_data_size) { + NDR_PULL_ALLOC(ndr, r->in.data_size); } else { - r->in.size = NULL; + r->in.data_size = NULL; } - if (r->in.size) { - _mem_save_size_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->in.size, 0); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->in.size)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_size_0, 0); + if (r->in.data_size) { + _mem_save_data_size_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.data_size, 0); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->in.data_size)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_size_0, 0); } - NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_length)); - if (_ptr_length) { - NDR_PULL_ALLOC(ndr, r->in.length); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_value_length)); + if (_ptr_value_length) { + NDR_PULL_ALLOC(ndr, r->in.value_length); } else { - r->in.length = NULL; + r->in.value_length = NULL; } - if (r->in.length) { - _mem_save_length_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->in.length, 0); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->in.length)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_length_0, 0); + if (r->in.value_length) { + _mem_save_value_length_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->in.value_length, 0); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->in.value_length)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_value_length_0, 0); } if (r->in.data) { - if (r->in.size == NULL) return NT_STATUS_INVALID_PARAMETER_MIX; - NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->in.data, *r->in.size)); + if (r->in.data_size == NULL) return NT_STATUS_INVALID_PARAMETER_MIX; + NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->in.data, *r->in.data_size)); } if (r->in.data) { - if (r->in.length == NULL) return NT_STATUS_INVALID_PARAMETER_MIX; - NDR_CHECK(ndr_check_array_length(ndr, (void*)&r->in.data, *r->in.length)); + if (r->in.value_length == NULL) return NT_STATUS_INVALID_PARAMETER_MIX; + NDR_CHECK(ndr_check_array_length(ndr, (void*)&r->in.data, *r->in.value_length)); } } if (flags & NDR_OUT) { @@ -2437,38 +2437,38 @@ NTSTATUS ndr_pull_winreg_QueryValue(struct ndr_pull *ndr, int flags, struct winr NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->out.data, ndr_get_array_length(ndr, &r->out.data))); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_0, 0); } - NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_size)); - if (_ptr_size) { - NDR_PULL_ALLOC(ndr, r->out.size); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_data_size)); + if (_ptr_data_size) { + NDR_PULL_ALLOC(ndr, r->out.data_size); } else { - r->out.size = NULL; + r->out.data_size = NULL; } - if (r->out.size) { - _mem_save_size_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->out.size, 0); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->out.size)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_size_0, 0); + if (r->out.data_size) { + _mem_save_data_size_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.data_size, 0); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->out.data_size)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_size_0, 0); } - NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_length)); - if (_ptr_length) { - NDR_PULL_ALLOC(ndr, r->out.length); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_value_length)); + if (_ptr_value_length) { + NDR_PULL_ALLOC(ndr, r->out.value_length); } else { - r->out.length = NULL; + r->out.value_length = NULL; } - if (r->out.length) { - _mem_save_length_0 = NDR_PULL_GET_MEM_CTX(ndr); - NDR_PULL_SET_MEM_CTX(ndr, r->out.length, 0); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->out.length)); - NDR_PULL_SET_MEM_CTX(ndr, _mem_save_length_0, 0); + if (r->out.value_length) { + _mem_save_value_length_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.value_length, 0); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->out.value_length)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_value_length_0, 0); } NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result)); if (r->out.data) { - if (r->out.size == NULL) return NT_STATUS_INVALID_PARAMETER_MIX; - NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->out.data, *r->out.size)); + if (r->out.data_size == NULL) return NT_STATUS_INVALID_PARAMETER_MIX; + NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->out.data, *r->out.data_size)); } if (r->out.data) { - if (r->out.length == NULL) return NT_STATUS_INVALID_PARAMETER_MIX; - NDR_CHECK(ndr_check_array_length(ndr, (void*)&r->out.data, *r->out.length)); + if (r->out.value_length == NULL) return NT_STATUS_INVALID_PARAMETER_MIX; + NDR_CHECK(ndr_check_array_length(ndr, (void*)&r->out.data, *r->out.value_length)); } } return NT_STATUS_OK; @@ -2498,19 +2498,19 @@ _PUBLIC_ void ndr_print_winreg_QueryValue(struct ndr_print *ndr, const char *nam ndr_print_ptr(ndr, "data", r->in.data); ndr->depth++; if (r->in.data) { - ndr_print_array_uint8(ndr, "data", r->in.data, *r->in.length); + ndr_print_array_uint8(ndr, "data", r->in.data, *r->in.value_length); } ndr->depth--; - ndr_print_ptr(ndr, "size", r->in.size); + ndr_print_ptr(ndr, "data_size", r->in.data_size); ndr->depth++; - if (r->in.size) { - ndr_print_uint32(ndr, "size", *r->in.size); + if (r->in.data_size) { + ndr_print_uint32(ndr, "data_size", *r->in.data_size); } ndr->depth--; - ndr_print_ptr(ndr, "length", r->in.length); + ndr_print_ptr(ndr, "value_length", r->in.value_length); ndr->depth++; - if (r->in.length) { - ndr_print_uint32(ndr, "length", *r->in.length); + if (r->in.value_length) { + ndr_print_uint32(ndr, "value_length", *r->in.value_length); } ndr->depth--; ndr->depth--; @@ -2527,19 +2527,19 @@ _PUBLIC_ void ndr_print_winreg_QueryValue(struct ndr_print *ndr, const char *nam ndr_print_ptr(ndr, "data", r->out.data); ndr->depth++; if (r->out.data) { - ndr_print_array_uint8(ndr, "data", r->out.data, *r->out.length); + ndr_print_array_uint8(ndr, "data", r->out.data, *r->out.value_length); } ndr->depth--; - ndr_print_ptr(ndr, "size", r->out.size); + ndr_print_ptr(ndr, "data_size", r->out.data_size); ndr->depth++; - if (r->out.size) { - ndr_print_uint32(ndr, "size", *r->out.size); + if (r->out.data_size) { + ndr_print_uint32(ndr, "data_size", *r->out.data_size); } ndr->depth--; - ndr_print_ptr(ndr, "length", r->out.length); + ndr_print_ptr(ndr, "value_length", r->out.value_length); ndr->depth++; - if (r->out.length) { - ndr_print_uint32(ndr, "length", *r->out.length); + if (r->out.value_length) { + ndr_print_uint32(ndr, "value_length", *r->out.value_length); } ndr->depth--; ndr_print_WERROR(ndr, "result", r->out.result); diff --git a/source3/librpc/gen_ndr/srv_winreg.c b/source3/librpc/gen_ndr/srv_winreg.c index 38a7ee93f38..a1acdf8741d 100644 --- a/source3/librpc/gen_ndr/srv_winreg.c +++ b/source3/librpc/gen_ndr/srv_winreg.c @@ -1108,9 +1108,9 @@ static BOOL api_winreg_QueryValue(pipes_struct *p) ZERO_STRUCT(r.out); r.out.type = r.in.type; r.out.data = r.in.data; - r.out.size = r.in.size; - r.out.length = r.in.length; - r.out.result = _winreg_QueryValue(p, r.in.handle, r.in.value_name, r.in.type, r.in.data, r.in.size, r.in.length); + r.out.data_size = r.in.data_size; + r.out.value_length = r.in.value_length; + r.out.result = _winreg_QueryValue(p, r.in.handle, r.in.value_name, r.in.type, r.in.data, r.in.data_size, r.in.value_length); if (DEBUGLEVEL >= 10) NDR_PRINT_OUT_DEBUG(winreg_QueryValue, &r); diff --git a/source3/librpc/gen_ndr/srv_winreg.h b/source3/librpc/gen_ndr/srv_winreg.h index 7fd3bfedd1e..1dd956a3afd 100644 --- a/source3/librpc/gen_ndr/srv_winreg.h +++ b/source3/librpc/gen_ndr/srv_winreg.h @@ -18,7 +18,7 @@ WERROR _winreg_LoadKey(pipes_struct *p, struct policy_handle *handle, struct win WERROR _winreg_NotifyChangeKeyValue(pipes_struct *p, struct policy_handle *handle, uint8_t watch_subtree, uint32_t notify_filter, uint32_t unknown, struct winreg_String string1, struct winreg_String string2, uint32_t unknown2); WERROR _winreg_OpenKey(pipes_struct *p, struct policy_handle *parent_handle, struct winreg_String keyname, uint32_t unknown, uint32_t access_mask, struct policy_handle *handle); WERROR _winreg_QueryInfoKey(pipes_struct *p, struct policy_handle *handle, struct winreg_String class_in, struct winreg_String *class_out, uint32_t *num_subkeys, uint32_t *max_subkeylen, uint32_t *max_subkeysize, uint32_t *num_values, uint32_t *max_valnamelen, uint32_t *max_valbufsize, uint32_t *secdescsize, NTTIME *last_changed_time); -WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, struct winreg_String value_name, enum winreg_Type *type, uint8_t *data, uint32_t *size, uint32_t *length); +WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, struct winreg_String value_name, enum winreg_Type *type, uint8_t *data, uint32_t *data_size, uint32_t *value_length); WERROR _winreg_ReplaceKey(pipes_struct *p); WERROR _winreg_RestoreKey(pipes_struct *p); WERROR _winreg_SaveKey(pipes_struct *p); diff --git a/source3/librpc/gen_ndr/winreg.h b/source3/librpc/gen_ndr/winreg.h index d895845243f..aa324ac0cea 100644 --- a/source3/librpc/gen_ndr/winreg.h +++ b/source3/librpc/gen_ndr/winreg.h @@ -334,16 +334,16 @@ struct winreg_QueryValue { struct policy_handle *handle;/* [ref] */ struct winreg_String value_name; enum winreg_Type *type;/* [unique] */ - uint8_t *data;/* [unique,length_is(*length),size_is(*size)] */ - uint32_t *size;/* [unique] */ - uint32_t *length;/* [unique] */ + uint8_t *data;/* [unique,length_is(*value_length),size_is(*data_size)] */ + uint32_t *data_size;/* [unique] */ + uint32_t *value_length;/* [unique] */ } in; struct { enum winreg_Type *type;/* [unique] */ - uint8_t *data;/* [unique,length_is(*length),size_is(*size)] */ - uint32_t *size;/* [unique] */ - uint32_t *length;/* [unique] */ + uint8_t *data;/* [unique,length_is(*value_length),size_is(*data_size)] */ + uint32_t *data_size;/* [unique] */ + uint32_t *value_length;/* [unique] */ WERROR result; } out; diff --git a/source3/librpc/idl/winreg.idl b/source3/librpc/idl/winreg.idl index 03b034b38f7..0a58362152e 100644 --- a/source3/librpc/idl/winreg.idl +++ b/source3/librpc/idl/winreg.idl @@ -226,9 +226,9 @@ [in,ref] policy_handle *handle, [in] winreg_String value_name, [in,out] winreg_Type *type, - [in,out,size_is(*size),length_is(*length)] uint8 *data, - [in,out] uint32 *size, - [in,out] uint32 *length + [in,out,size_is(*data_size),length_is(*value_length)] uint8 *data, + [in,out] uint32 *data_size, + [in,out] uint32 *value_length ); /******************/ diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 91435fc87e9..b874c5e5d11 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -350,7 +350,7 @@ WERROR _winreg_OpenKey(pipes_struct *p, struct policy_handle *parent_handle, str reg_reply_info ********************************************************************/ -WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, struct winreg_String value_name, enum winreg_Type *type, uint8_t *data, uint32_t *size, uint32_t *length) +WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, struct winreg_String value_name, enum winreg_Type *type, uint8_t *data, uint32_t *data_size, uint32_t *value_length) { WERROR status = WERR_BADFILE; char *name; @@ -362,7 +362,7 @@ WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, struct if ( !regkey ) return WERR_BADFID; - *size = *length = *type = 0; + *value_length = *type = 0; DEBUG(7,("_reg_info: policy key name = [%s]\n", regkey->name)); DEBUG(7,("_reg_info: policy key type = [%08x]\n", regkey->type)); @@ -383,8 +383,8 @@ WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, struct { uint32 outbuf_len; prs_struct prs_hkpd; - prs_init(&prs_hkpd, *size, p->mem_ctx, MARSHALL); - status = reg_perfcount_get_hkpd(&prs_hkpd, *size, &outbuf_len, NULL); + prs_init(&prs_hkpd, *data_size, p->mem_ctx, MARSHALL); + status = reg_perfcount_get_hkpd(&prs_hkpd, *data_size, &outbuf_len, NULL); regval_ctr_addvalue(regvals, "HKPD", REG_BINARY, prs_hkpd.data_p, outbuf_len); val = dup_registry_value(regval_ctr_specific_value(regvals, 0)); @@ -435,8 +435,8 @@ WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, struct /* we probably have a request for a specific object here */ uint32 outbuf_len; prs_struct prs_hkpd; - prs_init(&prs_hkpd, *size, p->mem_ctx, MARSHALL); - status = reg_perfcount_get_hkpd(&prs_hkpd, *size, &outbuf_len, name); + prs_init(&prs_hkpd, *data_size, p->mem_ctx, MARSHALL); + status = reg_perfcount_get_hkpd(&prs_hkpd, *data_size, &outbuf_len, name); regval_ctr_addvalue(regvals, "HKPD", REG_BINARY, prs_hkpd.data_p, outbuf_len); @@ -465,17 +465,20 @@ WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, struct } } + /* if we have a value then copy it to the output */ + if ( val ) { - *size = regval_size( val ); - *length = regval_size( val ); - -#if 0 - if ( (*data = talloc_memdup( p->mem_ctx, regval_data_p(val), *size )) == NULL ) { - status = WERR_NOMEM; - } -#endif - + *value_length = regval_size( val ); *type = val->type; + + if ( *data_size == 0 ) { + status = WERR_OK; + } else if ( *value_length > *data_size ) { + status = WERR_MORE_DATA; + } else { + memcpy( data, regval_data_p(val), *value_length ); + status = WERR_OK; + } } TALLOC_FREE( regvals );