diff options
-rw-r--r-- | source4/lib/registry/reg_backend_rpc/reg_backend_rpc.c | 43 | ||||
-rw-r--r-- | source4/librpc/idl/winreg.idl | 2 | ||||
-rw-r--r-- | source4/torture/rpc/winreg.c | 4 |
3 files changed, 34 insertions, 15 deletions
diff --git a/source4/lib/registry/reg_backend_rpc/reg_backend_rpc.c b/source4/lib/registry/reg_backend_rpc/reg_backend_rpc.c index 472a851638..6d1b293ee5 100644 --- a/source4/lib/registry/reg_backend_rpc/reg_backend_rpc.c +++ b/source4/lib/registry/reg_backend_rpc/reg_backend_rpc.c @@ -91,6 +91,8 @@ struct { { NULL, NULL } }; +static WERROR rpc_query_key(REG_KEY *k); + static WERROR rpc_open_registry(REG_HANDLE *h, const char *location, const char *credentials) { struct rpc_data *mydata = talloc(h->mem_ctx, sizeof(struct rpc_data)); @@ -204,27 +206,43 @@ static WERROR rpc_get_value_by_index(REG_KEY *parent, int n, REG_VAL **value) struct rpc_data *mydata = parent->handle->backend_data; struct winreg_EnumValueName vn; NTSTATUS status; - struct rpc_key_data *mykeydata = parent->backend_data; + struct rpc_key_data *mykeydata; uint32 type = 0x0, requested_len = 0, returned_len = 0; + WERROR error; + + error = rpc_key_put_rpc_data(parent, &mykeydata); + if(!W_ERROR_IS_OK(error)) return error; + + /* Root is a special case */ + if(parent->backend_data == parent->handle->backend_data) { + return WERR_NO_MORE_ITEMS; + } + + if(mykeydata->num_values == -1) { + error = rpc_query_key(parent); + if(!W_ERROR_IS_OK(error)) return error; + } + + requested_len = mykeydata->max_valdatalen; - /* FIXME */ - r.in.handle = &mykeydata->pol; r.in.enum_index = n; r.in.type = r.out.type = &type; r.in.requested_len = r.out.requested_len = &requested_len; r.in.returned_len = r.out.returned_len = &returned_len; - bn.max_len = mykeydata->max_valnamelen*3; - bn.offset = 0; - bn.len = 0; - bn.buffer = NULL; - vn.max_len = mykeydata->max_valnamelen*3; - vn.buf = &bn; + vn.max_len = mykeydata->max_valnamelen * 2; + vn.len = 0; + vn.buf = NULL; + if(vn.max_len > 0) { + vn.len = 0; + vn.max_len = mykeydata->max_valnamelen*2; + vn.buf = ""; + } r.in.name = r.out.name = &vn; - vb.max_len = mykeydata->max_valdatalen*3; + vb.max_len = mykeydata->max_valdatalen; vb.offset = 0x0; vb.len = 0x0; - vb.buffer = NULL; + vb.buffer = talloc_array_p(parent->mem_ctx, uint8, mykeydata->max_valdatalen); r.in.value = r.out.value = &vb; status = dcerpc_winreg_EnumValue(mydata->pipe, parent->mem_ctx, &r); @@ -234,10 +252,11 @@ static WERROR rpc_get_value_by_index(REG_KEY *parent, int n, REG_VAL **value) if(NT_STATUS_IS_OK(status) && W_ERROR_IS_OK(r.out.result)) { *value = reg_val_new(parent, NULL); - (*value)->name = (char *)r.out.name->buf->buffer; + (*value)->name = r.out.name->buf; (*value)->data_type = type; (*value)->data_len = r.out.value->len; (*value)->data_blk = r.out.value->buffer; + exit(1); return WERR_OK; } diff --git a/source4/librpc/idl/winreg.idl b/source4/librpc/idl/winreg.idl index 2fb30411d4..fa11f80dcd 100644 --- a/source4/librpc/idl/winreg.idl +++ b/source4/librpc/idl/winreg.idl @@ -132,7 +132,7 @@ typedef struct { uint16 len; uint16 max_len; - winreg_Uint16buf *buf; + unistr *buf; } winreg_EnumValueName; typedef struct { diff --git a/source4/torture/rpc/winreg.c b/source4/torture/rpc/winreg.c index 3323ea5d35..39010d1ea8 100644 --- a/source4/torture/rpc/winreg.c +++ b/source4/torture/rpc/winreg.c @@ -267,7 +267,7 @@ static BOOL test_EnumValue(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct winreg_EnumValue r; struct winreg_Uint8buf vb; struct winreg_EnumValueName vn; - uint32 type = 0, requested_len = 0, returned_len = 0; + uint32 type = 0, requested_len = max_valbufsize, returned_len = 0; NTSTATUS status; r.in.handle = handle; @@ -275,7 +275,7 @@ static BOOL test_EnumValue(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.type = &type; r.in.requested_len = &requested_len; r.in.returned_len = &returned_len; - vn.max_len = max_valnamelen; + vn.max_len = 0; vn.len = 0; vn.buf = NULL; r.in.name = r.out.name = &vn; |