mirror of
https://github.com/samba-team/samba.git
synced 2025-02-28 01:58:17 +03:00
winreg: Use the ntstatus return code for client side errors
cli_winreg.c functions indicate status to the caller in two ways. The ntstatus return code indicates client side errors, the pwerr argument carries the server response error code. Many functions are filling the pwerr argument on client side error, this change removes these cases. Signed-off-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
parent
d6cd1ee032
commit
1271066200
@ -60,19 +60,16 @@ NTSTATUS dcerpc_winreg_query_dword(TALLOC_CTX *mem_ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (type != REG_DWORD) {
|
if (type != REG_DWORD) {
|
||||||
*pwerr = WERR_INVALID_DATATYPE;
|
return NT_STATUS_OBJECT_TYPE_MISMATCH;
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data_size != 4) {
|
if (data_size != 4) {
|
||||||
*pwerr = WERR_INVALID_DATA;
|
return NT_STATUS_INVALID_PARAMETER;
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
blob = data_blob_talloc_zero(mem_ctx, data_size);
|
blob = data_blob_talloc_zero(mem_ctx, data_size);
|
||||||
if (blob.data == NULL) {
|
if (blob.data == NULL) {
|
||||||
*pwerr = WERR_NOMEM;
|
return NT_STATUS_NO_MEMORY;
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
value_len = 0;
|
value_len = 0;
|
||||||
|
|
||||||
@ -136,14 +133,12 @@ NTSTATUS dcerpc_winreg_query_binary(TALLOC_CTX *mem_ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (type != REG_BINARY) {
|
if (type != REG_BINARY) {
|
||||||
*pwerr = WERR_INVALID_DATATYPE;
|
return NT_STATUS_OBJECT_TYPE_MISMATCH;
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
blob = data_blob_talloc_zero(mem_ctx, data_size);
|
blob = data_blob_talloc_zero(mem_ctx, data_size);
|
||||||
if (blob.data == NULL) {
|
if (blob.data == NULL) {
|
||||||
*pwerr = WERR_NOMEM;
|
return NT_STATUS_NO_MEMORY;
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
value_len = 0;
|
value_len = 0;
|
||||||
|
|
||||||
@ -207,14 +202,12 @@ NTSTATUS dcerpc_winreg_query_multi_sz(TALLOC_CTX *mem_ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (type != REG_MULTI_SZ) {
|
if (type != REG_MULTI_SZ) {
|
||||||
*pwerr = WERR_INVALID_DATATYPE;
|
return NT_STATUS_OBJECT_TYPE_MISMATCH;
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
blob = data_blob_talloc_zero(mem_ctx, data_size);
|
blob = data_blob_talloc_zero(mem_ctx, data_size);
|
||||||
if (blob.data == NULL) {
|
if (blob.data == NULL) {
|
||||||
*pwerr = WERR_NOMEM;
|
return NT_STATUS_NO_MEMORY;
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
value_len = 0;
|
value_len = 0;
|
||||||
|
|
||||||
@ -240,7 +233,7 @@ NTSTATUS dcerpc_winreg_query_multi_sz(TALLOC_CTX *mem_ctx,
|
|||||||
|
|
||||||
ok = pull_reg_multi_sz(mem_ctx, &blob, data);
|
ok = pull_reg_multi_sz(mem_ctx, &blob, data);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
*pwerr = WERR_NOMEM;
|
status = NT_STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,14 +275,12 @@ NTSTATUS dcerpc_winreg_query_sz(TALLOC_CTX *mem_ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (type != REG_SZ) {
|
if (type != REG_SZ) {
|
||||||
*pwerr = WERR_INVALID_DATATYPE;
|
return NT_STATUS_OBJECT_TYPE_MISMATCH;
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
blob = data_blob_talloc_zero(mem_ctx, data_size);
|
blob = data_blob_talloc_zero(mem_ctx, data_size);
|
||||||
if (blob.data == NULL) {
|
if (blob.data == NULL) {
|
||||||
*pwerr = WERR_NOMEM;
|
return NT_STATUS_NO_MEMORY;
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
value_len = 0;
|
value_len = 0;
|
||||||
|
|
||||||
@ -315,7 +306,7 @@ NTSTATUS dcerpc_winreg_query_sz(TALLOC_CTX *mem_ctx,
|
|||||||
|
|
||||||
ok = pull_reg_sz(mem_ctx, &blob, data);
|
ok = pull_reg_sz(mem_ctx, &blob, data);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
*pwerr = WERR_NOMEM;
|
status = NT_STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -353,8 +344,7 @@ NTSTATUS dcerpc_winreg_query_sd(TALLOC_CTX *mem_ctx,
|
|||||||
|
|
||||||
sd = talloc_zero(mem_ctx, struct security_descriptor);
|
sd = talloc_zero(mem_ctx, struct security_descriptor);
|
||||||
if (sd == NULL) {
|
if (sd == NULL) {
|
||||||
*pwerr = WERR_NOMEM;
|
return NT_STATUS_NO_MEMORY;
|
||||||
return NT_STATUS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ndr_err = ndr_pull_struct_blob(&blob,
|
ndr_err = ndr_pull_struct_blob(&blob,
|
||||||
@ -364,8 +354,7 @@ NTSTATUS dcerpc_winreg_query_sd(TALLOC_CTX *mem_ctx,
|
|||||||
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
|
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
|
||||||
DEBUG(2, ("dcerpc_winreg_query_sd: Failed to marshall "
|
DEBUG(2, ("dcerpc_winreg_query_sd: Failed to marshall "
|
||||||
"security descriptor\n"));
|
"security descriptor\n"));
|
||||||
*pwerr = WERR_NOMEM;
|
return NT_STATUS_NO_MEMORY;
|
||||||
return NT_STATUS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*data = sd;
|
*data = sd;
|
||||||
@ -429,8 +418,7 @@ NTSTATUS dcerpc_winreg_set_sz(TALLOC_CTX *mem_ctx,
|
|||||||
DEBUG(2, ("dcerpc_winreg_set_sz: Could not marshall "
|
DEBUG(2, ("dcerpc_winreg_set_sz: Could not marshall "
|
||||||
"string %s for %s\n",
|
"string %s for %s\n",
|
||||||
data, wvalue.name));
|
data, wvalue.name));
|
||||||
*pwerr = WERR_NOMEM;
|
return NT_STATUS_NO_MEMORY;
|
||||||
return NT_STATUS_OK;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -472,8 +460,7 @@ NTSTATUS dcerpc_winreg_set_expand_sz(TALLOC_CTX *mem_ctx,
|
|||||||
DEBUG(2, ("dcerpc_winreg_set_expand_sz: Could not marshall "
|
DEBUG(2, ("dcerpc_winreg_set_expand_sz: Could not marshall "
|
||||||
"string %s for %s\n",
|
"string %s for %s\n",
|
||||||
data, wvalue.name));
|
data, wvalue.name));
|
||||||
*pwerr = WERR_NOMEM;
|
return NT_STATUS_NO_MEMORY;
|
||||||
return NT_STATUS_OK;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -512,8 +499,7 @@ NTSTATUS dcerpc_winreg_set_multi_sz(TALLOC_CTX *mem_ctx,
|
|||||||
DEBUG(2, ("dcerpc_winreg_set_multi_sz: Could not marshall "
|
DEBUG(2, ("dcerpc_winreg_set_multi_sz: Could not marshall "
|
||||||
"string multi sz for %s\n",
|
"string multi sz for %s\n",
|
||||||
wvalue.name));
|
wvalue.name));
|
||||||
*pwerr = WERR_NOMEM;
|
return NT_STATUS_NO_MEMORY;
|
||||||
return NT_STATUS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
status = dcerpc_winreg_SetValue(h,
|
status = dcerpc_winreg_SetValue(h,
|
||||||
@ -582,8 +568,7 @@ NTSTATUS dcerpc_winreg_set_sd(TALLOC_CTX *mem_ctx,
|
|||||||
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
|
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
|
||||||
DEBUG(2, ("dcerpc_winreg_set_sd: Failed to marshall security "
|
DEBUG(2, ("dcerpc_winreg_set_sd: Failed to marshall security "
|
||||||
"descriptor\n"));
|
"descriptor\n"));
|
||||||
*pwerr = WERR_NOMEM;
|
return NT_STATUS_NO_MEMORY;
|
||||||
return NT_STATUS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return dcerpc_winreg_set_binary(mem_ctx,
|
return dcerpc_winreg_set_binary(mem_ctx,
|
||||||
@ -619,8 +604,7 @@ NTSTATUS dcerpc_winreg_add_multi_sz(TALLOC_CTX *mem_ctx,
|
|||||||
|
|
||||||
p = talloc_realloc(mem_ctx, a, const char *, i + 2);
|
p = talloc_realloc(mem_ctx, a, const char *, i + 2);
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
*pwerr = WERR_NOMEM;
|
return NT_STATUS_NO_MEMORY;
|
||||||
return NT_STATUS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
p[i] = data;
|
p[i] = data;
|
||||||
@ -684,14 +668,14 @@ NTSTATUS dcerpc_winreg_enum_keys(TALLOC_CTX *mem_ctx,
|
|||||||
|
|
||||||
subkeys = talloc_zero_array(tmp_ctx, const char *, num_subkeys + 2);
|
subkeys = talloc_zero_array(tmp_ctx, const char *, num_subkeys + 2);
|
||||||
if (subkeys == NULL) {
|
if (subkeys == NULL) {
|
||||||
*pwerr = WERR_NOMEM;
|
status = NT_STATUS_NO_MEMORY;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num_subkeys == 0) {
|
if (num_subkeys == 0) {
|
||||||
subkeys[0] = talloc_strdup(subkeys, "");
|
subkeys[0] = talloc_strdup(subkeys, "");
|
||||||
if (subkeys[0] == NULL) {
|
if (subkeys[0] == NULL) {
|
||||||
*pwerr = WERR_NOMEM;
|
status = NT_STATUS_NO_MEMORY;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
*pnum_subkeys = 0;
|
*pnum_subkeys = 0;
|
||||||
@ -753,7 +737,7 @@ NTSTATUS dcerpc_winreg_enum_keys(TALLOC_CTX *mem_ctx,
|
|||||||
|
|
||||||
name = talloc_strdup(subkeys, name_buf.name);
|
name = talloc_strdup(subkeys, name_buf.name);
|
||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
*pwerr = WERR_NOMEM;
|
status = NT_STATUS_NO_MEMORY;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user