diff --git a/source/rpc_server/winreg/rpc_winreg.c b/source/rpc_server/winreg/rpc_winreg.c index 22c60c3..c8781d9 100644 --- a/source/rpc_server/winreg/rpc_winreg.c +++ b/source/rpc_server/winreg/rpc_winreg.c @@ -222,16 +222,14 @@ static WERROR dcesrv_winreg_EnumKey(struct dcesrv_call_state *dce_call, r->in.enum_index, &name, NULL, &last_mod); - if (W_ERROR_IS_OK(r->out.result)) { - if (2*strlen_m_term(name) > r->in.name->size) { - return WERR_MORE_DATA; - } - r->out.name->length = 2*strlen_m_term(name); - r->out.name->name = name; - r->out.keyclass = talloc_zero(mem_ctx, struct winreg_StringBuf); - if (r->in.last_changed_time) { - r->out.last_changed_time = &last_mod; - } + if (2*strlen_m_term(name) > r->in.name->size) { + return WERR_MORE_DATA; + } + r->out.name->length = 2*strlen_m_term(name); + r->out.name->name = name; + r->out.keyclass = talloc_zero(mem_ctx, struct winreg_StringBuf); + if (r->in.last_changed_time) { + r->out.last_changed_time = &last_mod; } return r->out.result; @@ -259,8 +257,13 @@ static WERROR dcesrv_winreg_EnumValue(struct dcesrv_call_state *dce_call, result = reg_key_get_value_by_index(mem_ctx, key, r->in.enum_index, &data_name, &data_type, &data); + if (!W_ERROR_IS_OK(result)) { - return result; + /* if the lookup wasn't successful, send client query back */ + data_name = r->in.name->name; + data_type = *r->in.type; + data.data = r->in.value; + data.length = *r->in.length; } /* the client can optionally pass a NULL for type, meaning they don't @@ -296,7 +299,7 @@ static WERROR dcesrv_winreg_EnumValue(struct dcesrv_call_state *dce_call, r->out.length = r->out.size; } - return WERR_OK; + return result; } @@ -408,7 +411,7 @@ static WERROR dcesrv_winreg_QueryInfoKey(struct dcesrv_call_state *dce_call, { struct dcesrv_handle *h; struct registry_key *k; - WERROR ret; + WERROR result; const char *classname = NULL; DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY); @@ -420,7 +423,7 @@ static WERROR dcesrv_winreg_QueryInfoKey(struct dcesrv_call_state *dce_call, case SECURITY_USER: k = h->data; - ret = reg_key_get_info(mem_ctx, k, &classname, r->out.num_subkeys, + result = reg_key_get_info(mem_ctx, k, &classname, r->out.num_subkeys, r->out.num_values, r->out.last_changed_time, r->out.max_subkeylen, r->out.max_valnamelen, r->out.max_valbufsize); @@ -428,7 +431,7 @@ static WERROR dcesrv_winreg_QueryInfoKey(struct dcesrv_call_state *dce_call, if (r->out.classname != NULL) r->out.classname->name = classname; - return ret; + return result; default: return WERR_ACCESS_DENIED; } @@ -444,9 +447,9 @@ static WERROR dcesrv_winreg_QueryValue(struct dcesrv_call_state *dce_call, { struct dcesrv_handle *h; struct registry_key *key; + WERROR result; uint32_t value_type; DATA_BLOB value_data; - WERROR result; DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY); @@ -460,10 +463,14 @@ static WERROR dcesrv_winreg_QueryValue(struct dcesrv_call_state *dce_call, result = reg_key_get_value_by_name(mem_ctx, key, r->in.value_name.name, &value_type, &value_data); + if (!W_ERROR_IS_OK(result)) { - return result; + /* if the lookup wasn't successful, send client query back */ + value_type = *r->in.type; + value_data.data = r->in.data; + value_data.length = *r->in.length; } - + /* Just asking for the size of the buffer */ r->out.type = talloc(mem_ctx, uint32_t); if (!r->out.type) { @@ -483,7 +490,7 @@ static WERROR dcesrv_winreg_QueryValue(struct dcesrv_call_state *dce_call, r->out.data = value_data.data; } - return WERR_OK; + return result; default: return WERR_ACCESS_DENIED; }