From 529763a9aa192a6785ba878aceeb1683c2510913 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 9 Nov 2007 19:24:51 +0100 Subject: r25920: ndr: change NTSTAUS into enum ndr_err_code (samba4 callers) lib/messaging/ lib/registry/ lib/ldb-samba/ librpc/rpc/ auth/auth_winbind.c auth/gensec/ auth/kerberos/ dsdb/repl/ dsdb/samdb/ dsdb/schema/ torture/ cluster/ctdb/ kdc/ ntvfs/ipc/ torture/rap/ ntvfs/ utils/getntacl.c ntptr/ smb_server/ libcli/wrepl/ wrepl_server/ libcli/cldap/ libcli/dgram/ libcli/ldap/ libcli/raw/ libcli/nbt/ libnet/ winbind/ rpc_server/ metze (This used to be commit 6223c7fddc972687eb577e04fc1c8e0604c35435) --- source4/libcli/cldap/cldap.c | 17 ++++--- source4/libcli/dgram/browse.c | 25 +++++----- source4/libcli/dgram/dgramsocket.c | 14 ++++-- source4/libcli/dgram/netlogon.c | 25 +++++----- source4/libcli/dgram/ntlogon.c | 25 +++++----- source4/libcli/ldap/ldap_ndr.c | 27 ++++++----- source4/libcli/nbt/nbtname.c | 95 +++++++++++++++++++++---------------- source4/libcli/nbt/nbtsocket.c | 26 +++++----- source4/libcli/raw/rawacl.c | 16 ++++--- source4/libcli/raw/rawfile.c | 10 ++-- source4/libcli/raw/rawfileinfo.c | 12 +++-- source4/libcli/raw/rawfsinfo.c | 8 +++- source4/libcli/raw/rawsetfileinfo.c | 14 +++--- source4/libcli/wrepl/winsrepl.c | 19 ++++---- 14 files changed, 193 insertions(+), 140 deletions(-) (limited to 'source4/libcli') diff --git a/source4/libcli/cldap/cldap.c b/source4/libcli/cldap/cldap.c index 54b5995377..9903595dfb 100644 --- a/source4/libcli/cldap/cldap.c +++ b/source4/libcli/cldap/cldap.c @@ -595,6 +595,7 @@ NTSTATUS cldap_netlogon_recv(struct cldap_request *req, struct cldap_netlogon *io) { NTSTATUS status; + enum ndr_err_code ndr_err; struct cldap_search search; DATA_BLOB *data; @@ -614,13 +615,14 @@ NTSTATUS cldap_netlogon_recv(struct cldap_request *req, } data = search.out.response->attributes[0].values; - status = ndr_pull_union_blob_all(data, mem_ctx, &io->out.netlogon, - io->in.version & 0xF, - (ndr_pull_flags_fn_t)ndr_pull_nbt_cldap_netlogon); - if (!NT_STATUS_IS_OK(status)) { + ndr_err = ndr_pull_union_blob_all(data, mem_ctx, &io->out.netlogon, + io->in.version & 0xF, + (ndr_pull_flags_fn_t)ndr_pull_nbt_cldap_netlogon); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { DEBUG(2,("cldap failed to parse netlogon response of type 0x%02x\n", SVAL(data->data, 0))); dump_data(10, data->data, data->length); + return ndr_map_error2ntstatus(ndr_err); } return NT_STATUS_OK; @@ -700,17 +702,18 @@ NTSTATUS cldap_netlogon_reply(struct cldap_socket *cldap, union nbt_cldap_netlogon *netlogon) { NTSTATUS status; + enum ndr_err_code ndr_err; struct cldap_reply reply; struct ldap_SearchResEntry response; struct ldap_Result result; TALLOC_CTX *tmp_ctx = talloc_new(cldap); DATA_BLOB blob; - status = ndr_push_union_blob(&blob, tmp_ctx, netlogon, version & 0xF, + ndr_err = ndr_push_union_blob(&blob, tmp_ctx, netlogon, version & 0xF, (ndr_push_flags_fn_t)ndr_push_nbt_cldap_netlogon); - if (!NT_STATUS_IS_OK(status)) { + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { talloc_free(tmp_ctx); - return status; + return ndr_map_error2ntstatus(ndr_err); } reply.messageid = message_id; diff --git a/source4/libcli/dgram/browse.c b/source4/libcli/dgram/browse.c index 3e78378732..3b5f67118f 100644 --- a/source4/libcli/dgram/browse.c +++ b/source4/libcli/dgram/browse.c @@ -34,14 +34,15 @@ NTSTATUS dgram_mailslot_browse_send(struct nbt_dgram_socket *dgmsock, struct nbt_browse_packet *request) { NTSTATUS status; + enum ndr_err_code ndr_err; DATA_BLOB blob; TALLOC_CTX *tmp_ctx = talloc_new(dgmsock); - status = ndr_push_struct_blob(&blob, tmp_ctx, request, + ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, request, (ndr_push_flags_fn_t)ndr_push_nbt_browse_packet); - if (!NT_STATUS_IS_OK(status)) { + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { talloc_free(tmp_ctx); - return status; + return ndr_map_error2ntstatus(ndr_err); } status = dgram_mailslot_send(dgmsock, DGRAM_DIRECT_UNIQUE, @@ -58,16 +59,17 @@ NTSTATUS dgram_mailslot_browse_reply(struct nbt_dgram_socket *dgmsock, struct nbt_browse_packet *reply) { NTSTATUS status; + enum ndr_err_code ndr_err; DATA_BLOB blob; TALLOC_CTX *tmp_ctx = talloc_new(dgmsock); struct nbt_name myname; struct socket_address *dest; - status = ndr_push_struct_blob(&blob, tmp_ctx, reply, + ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, reply, (ndr_push_flags_fn_t)ndr_push_nbt_browse_packet); - if (!NT_STATUS_IS_OK(status)) { + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { talloc_free(tmp_ctx); - return status; + return ndr_map_error2ntstatus(ndr_err); } make_nbt_name_client(&myname, lp_netbios_name(global_loadparm)); @@ -94,13 +96,14 @@ NTSTATUS dgram_mailslot_browse_parse(struct dgram_mailslot_handler *dgmslot, struct nbt_browse_packet *pkt) { DATA_BLOB data = dgram_mailslot_data(dgram); - NTSTATUS status; + enum ndr_err_code ndr_err; - status = ndr_pull_struct_blob(&data, mem_ctx, pkt, + ndr_err = ndr_pull_struct_blob(&data, mem_ctx, pkt, (ndr_pull_flags_fn_t)ndr_pull_nbt_browse_packet); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0,("Failed to parse browse packet of length %d\n", - (int)data.length)); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + NTSTATUS status = ndr_map_error2ntstatus(ndr_err); + DEBUG(0,("Failed to parse browse packet of length %d: %s\n", + (int)data.length, nt_errstr(status))); if (DEBUGLVL(10)) { file_save("browse.dat", data.data, data.length); } diff --git a/source4/libcli/dgram/dgramsocket.c b/source4/libcli/dgram/dgramsocket.c index 1097c30f99..1af252c0bf 100644 --- a/source4/libcli/dgram/dgramsocket.c +++ b/source4/libcli/dgram/dgramsocket.c @@ -39,6 +39,7 @@ static void dgm_socket_recv(struct nbt_dgram_socket *dgmsock) size_t nread, dsize; struct nbt_dgram_packet *packet; const char *mailslot_name; + enum ndr_err_code ndr_err; status = socket_pending(dgmsock->sock, &dsize); if (!NT_STATUS_IS_OK(status)) { @@ -70,9 +71,10 @@ static void dgm_socket_recv(struct nbt_dgram_socket *dgmsock) } /* parse the request */ - status = ndr_pull_struct_blob(&blob, packet, packet, + ndr_err = ndr_pull_struct_blob(&blob, packet, packet, (ndr_pull_flags_fn_t)ndr_pull_nbt_dgram_packet); - if (!NT_STATUS_IS_OK(status)) { + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + status = ndr_map_error2ntstatus(ndr_err); DEBUG(2,("Failed to parse incoming NBT DGRAM packet - %s\n", nt_errstr(status))); talloc_free(tmp_ctx); @@ -218,6 +220,7 @@ NTSTATUS nbt_dgram_send(struct nbt_dgram_socket *dgmsock, { struct nbt_dgram_request *req; NTSTATUS status = NT_STATUS_NO_MEMORY; + enum ndr_err_code ndr_err; req = talloc(dgmsock, struct nbt_dgram_request); if (req == NULL) goto failed; @@ -225,9 +228,12 @@ NTSTATUS nbt_dgram_send(struct nbt_dgram_socket *dgmsock, req->dest = dest; if (talloc_reference(req, dest) == NULL) goto failed; - status = ndr_push_struct_blob(&req->encoded, req, packet, + ndr_err = ndr_push_struct_blob(&req->encoded, req, packet, (ndr_push_flags_fn_t)ndr_push_nbt_dgram_packet); - if (!NT_STATUS_IS_OK(status)) goto failed; + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + status = ndr_map_error2ntstatus(ndr_err); + goto failed; + } DLIST_ADD_END(dgmsock->send_queue, req, struct nbt_dgram_request *); diff --git a/source4/libcli/dgram/netlogon.c b/source4/libcli/dgram/netlogon.c index 3a5510b408..f89c2c5644 100644 --- a/source4/libcli/dgram/netlogon.c +++ b/source4/libcli/dgram/netlogon.c @@ -36,14 +36,15 @@ NTSTATUS dgram_mailslot_netlogon_send(struct nbt_dgram_socket *dgmsock, struct nbt_netlogon_packet *request) { NTSTATUS status; + enum ndr_err_code ndr_err; DATA_BLOB blob; TALLOC_CTX *tmp_ctx = talloc_new(dgmsock); - status = ndr_push_struct_blob(&blob, tmp_ctx, request, + ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, request, (ndr_push_flags_fn_t)ndr_push_nbt_netlogon_packet); - if (!NT_STATUS_IS_OK(status)) { + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { talloc_free(tmp_ctx); - return status; + return ndr_map_error2ntstatus(ndr_err); } @@ -65,16 +66,17 @@ NTSTATUS dgram_mailslot_netlogon_reply(struct nbt_dgram_socket *dgmsock, struct nbt_netlogon_packet *reply) { NTSTATUS status; + enum ndr_err_code ndr_err; DATA_BLOB blob; TALLOC_CTX *tmp_ctx = talloc_new(dgmsock); struct nbt_name myname; struct socket_address *dest; - status = ndr_push_struct_blob(&blob, tmp_ctx, reply, + ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, reply, (ndr_push_flags_fn_t)ndr_push_nbt_netlogon_packet); - if (!NT_STATUS_IS_OK(status)) { + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { talloc_free(tmp_ctx); - return status; + return ndr_map_error2ntstatus(ndr_err); } make_nbt_name_client(&myname, lp_netbios_name(global_loadparm)); @@ -105,13 +107,14 @@ NTSTATUS dgram_mailslot_netlogon_parse(struct dgram_mailslot_handler *dgmslot, struct nbt_netlogon_packet *netlogon) { DATA_BLOB data = dgram_mailslot_data(dgram); - NTSTATUS status; + enum ndr_err_code ndr_err; - status = ndr_pull_struct_blob(&data, mem_ctx, netlogon, + ndr_err = ndr_pull_struct_blob(&data, mem_ctx, netlogon, (ndr_pull_flags_fn_t)ndr_pull_nbt_netlogon_packet); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0,("Failed to parse netlogon packet of length %d\n", - (int)data.length)); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + NTSTATUS status = ndr_map_error2ntstatus(ndr_err); + DEBUG(0,("Failed to parse netlogon packet of length %d: %s\n", + (int)data.length, nt_errstr(status))); if (DEBUGLVL(10)) { file_save("netlogon.dat", data.data, data.length); } diff --git a/source4/libcli/dgram/ntlogon.c b/source4/libcli/dgram/ntlogon.c index a49f011bda..b4b548fb27 100644 --- a/source4/libcli/dgram/ntlogon.c +++ b/source4/libcli/dgram/ntlogon.c @@ -37,14 +37,15 @@ NTSTATUS dgram_mailslot_ntlogon_send(struct nbt_dgram_socket *dgmsock, struct nbt_ntlogon_packet *request) { NTSTATUS status; + enum ndr_err_code ndr_err; DATA_BLOB blob; TALLOC_CTX *tmp_ctx = talloc_new(dgmsock); - status = ndr_push_struct_blob(&blob, tmp_ctx, request, + ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, request, (ndr_push_flags_fn_t)ndr_push_nbt_ntlogon_packet); - if (!NT_STATUS_IS_OK(status)) { + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { talloc_free(tmp_ctx); - return status; + return ndr_map_error2ntstatus(ndr_err); } @@ -66,16 +67,17 @@ NTSTATUS dgram_mailslot_ntlogon_reply(struct nbt_dgram_socket *dgmsock, struct nbt_ntlogon_packet *reply) { NTSTATUS status; + enum ndr_err_code ndr_err; DATA_BLOB blob; TALLOC_CTX *tmp_ctx = talloc_new(dgmsock); struct nbt_name myname; struct socket_address *dest; - status = ndr_push_struct_blob(&blob, tmp_ctx, reply, + ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, reply, (ndr_push_flags_fn_t)ndr_push_nbt_ntlogon_packet); - if (!NT_STATUS_IS_OK(status)) { + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { talloc_free(tmp_ctx); - return status; + return ndr_map_error2ntstatus(ndr_err); } make_nbt_name_client(&myname, lp_netbios_name(global_loadparm)); @@ -107,13 +109,14 @@ NTSTATUS dgram_mailslot_ntlogon_parse(struct dgram_mailslot_handler *dgmslot, struct nbt_ntlogon_packet *ntlogon) { DATA_BLOB data = dgram_mailslot_data(dgram); - NTSTATUS status; + enum ndr_err_code ndr_err; - status = ndr_pull_struct_blob(&data, mem_ctx, ntlogon, + ndr_err = ndr_pull_struct_blob(&data, mem_ctx, ntlogon, (ndr_pull_flags_fn_t)ndr_pull_nbt_ntlogon_packet); - if (!NT_STATUS_IS_OK(status)) { - DEBUG(0,("Failed to parse ntlogon packet of length %d\n", - (int)data.length)); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + NTSTATUS status = ndr_map_error2ntstatus(ndr_err); + DEBUG(0,("Failed to parse ntlogon packet of length %d: %s\n", + (int)data.length, nt_errstr(status))); if (DEBUGLVL(10)) { file_save("ntlogon.dat", data.data, data.length); } diff --git a/source4/libcli/ldap/ldap_ndr.c b/source4/libcli/ldap/ldap_ndr.c index a5f90cf82b..468c366c85 100644 --- a/source4/libcli/ldap/ldap_ndr.c +++ b/source4/libcli/ldap/ldap_ndr.c @@ -44,11 +44,11 @@ char *ldap_encode_ndr_uint32(TALLOC_CTX *mem_ctx, uint32_t value) char *ldap_encode_ndr_dom_sid(TALLOC_CTX *mem_ctx, const struct dom_sid *sid) { DATA_BLOB blob; - NTSTATUS status; + enum ndr_err_code ndr_err; char *ret; - status = ndr_push_struct_blob(&blob, mem_ctx, sid, - (ndr_push_flags_fn_t)ndr_push_dom_sid); - if (!NT_STATUS_IS_OK(status)) { + ndr_err = ndr_push_struct_blob(&blob, mem_ctx, sid, + (ndr_push_flags_fn_t)ndr_push_dom_sid); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { return NULL; } ret = ldb_binary_encode(mem_ctx, blob); @@ -63,11 +63,11 @@ char *ldap_encode_ndr_dom_sid(TALLOC_CTX *mem_ctx, const struct dom_sid *sid) char *ldap_encode_ndr_GUID(TALLOC_CTX *mem_ctx, struct GUID *guid) { DATA_BLOB blob; - NTSTATUS status; + enum ndr_err_code ndr_err; char *ret; - status = ndr_push_struct_blob(&blob, mem_ctx, guid, - (ndr_push_flags_fn_t)ndr_push_GUID); - if (!NT_STATUS_IS_OK(status)) { + ndr_err = ndr_push_struct_blob(&blob, mem_ctx, guid, + (ndr_push_flags_fn_t)ndr_push_GUID); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { return NULL; } ret = ldb_binary_encode(mem_ctx, blob); @@ -81,12 +81,15 @@ char *ldap_encode_ndr_GUID(TALLOC_CTX *mem_ctx, struct GUID *guid) NTSTATUS ldap_decode_ndr_GUID(TALLOC_CTX *mem_ctx, struct ldb_val val, struct GUID *guid) { DATA_BLOB blob; - NTSTATUS status; + enum ndr_err_code ndr_err; blob.data = val.data; blob.length = val.length; - status = ndr_pull_struct_blob(&blob, mem_ctx, guid, - (ndr_pull_flags_fn_t)ndr_pull_GUID); + ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, guid, + (ndr_pull_flags_fn_t)ndr_pull_GUID); talloc_free(val.data); - return status; + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + return ndr_map_error2ntstatus(ndr_err); + } + return NT_STATUS_OK; } diff --git a/source4/libcli/nbt/nbtname.c b/source4/libcli/nbt/nbtname.c index 1ee421b1f7..bdcd012556 100644 --- a/source4/libcli/nbt/nbtname.c +++ b/source4/libcli/nbt/nbtname.c @@ -42,8 +42,10 @@ _PUBLIC_ void ndr_print_nbt_string(struct ndr_print *ndr, const char *name, cons /* pull one component of a nbt_string */ -static NTSTATUS ndr_pull_component(struct ndr_pull *ndr, uint8_t **component, - uint32_t *offset, uint32_t *max_offset) +static enum ndr_err_code ndr_pull_component(struct ndr_pull *ndr, + uint8_t **component, + uint32_t *offset, + uint32_t *max_offset) { uint8_t len; uint_t loops = 0; @@ -57,7 +59,7 @@ static NTSTATUS ndr_pull_component(struct ndr_pull *ndr, uint8_t **component, *offset += 1; *max_offset = MAX(*max_offset, *offset); *component = NULL; - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } if ((len & 0xC0) == 0xC0) { /* its a label pointer */ @@ -81,10 +83,10 @@ static NTSTATUS ndr_pull_component(struct ndr_pull *ndr, uint8_t **component, "BAD NBT NAME component"); } *component = (uint8_t*)talloc_strndup(ndr, (const char *)&ndr->data[1 + *offset], len); - NT_STATUS_HAVE_NO_MEMORY(*component); + NDR_ERR_HAVE_NO_MEMORY(*component); *offset += len + 1; *max_offset = MAX(*max_offset, *offset); - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /* too many pointers */ @@ -94,7 +96,7 @@ static NTSTATUS ndr_pull_component(struct ndr_pull *ndr, uint8_t **component, /** pull a nbt_string from the wire */ -_PUBLIC_ NTSTATUS ndr_pull_nbt_string(struct ndr_pull *ndr, int ndr_flags, const char **s) +_PUBLIC_ enum ndr_err_code ndr_pull_nbt_string(struct ndr_pull *ndr, int ndr_flags, const char **s) { uint32_t offset = ndr->offset; uint32_t max_offset = offset; @@ -102,7 +104,7 @@ _PUBLIC_ NTSTATUS ndr_pull_nbt_string(struct ndr_pull *ndr, int ndr_flags, const char *name; if (!(ndr_flags & NDR_SCALARS)) { - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } name = NULL; @@ -114,7 +116,7 @@ _PUBLIC_ NTSTATUS ndr_pull_nbt_string(struct ndr_pull *ndr, int ndr_flags, const if (component == NULL) break; if (name) { name = talloc_asprintf_append_buffer(name, ".%s", component); - NT_STATUS_HAVE_NO_MEMORY(name); + NDR_ERR_HAVE_NO_MEMORY(name); } else { name = (char *)component; } @@ -125,26 +127,26 @@ _PUBLIC_ NTSTATUS ndr_pull_nbt_string(struct ndr_pull *ndr, int ndr_flags, const } if (num_components == 0) { name = talloc_strdup(ndr, ""); - NT_STATUS_HAVE_NO_MEMORY(name); + NDR_ERR_HAVE_NO_MEMORY(name); } (*s) = name; ndr->offset = max_offset; - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /** push a nbt string to the wire */ -_PUBLIC_ NTSTATUS ndr_push_nbt_string(struct ndr_push *ndr, int ndr_flags, const char *s) +_PUBLIC_ enum ndr_err_code ndr_push_nbt_string(struct ndr_push *ndr, int ndr_flags, const char *s) { if (!(ndr_flags & NDR_SCALARS)) { - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } while (s && *s) { - NTSTATUS status; + enum ndr_err_code ndr_err; char *compname; size_t complen; uint32_t offset; @@ -152,8 +154,8 @@ _PUBLIC_ NTSTATUS ndr_push_nbt_string(struct ndr_push *ndr, int ndr_flags, const /* see if we have pushed the remaing string allready, * if so we use a label pointer to this string */ - status = ndr_token_retrieve_cmp_fn(&ndr->nbt_string_list, s, &offset, (comparison_fn_t)strcmp, false); - if (NT_STATUS_IS_OK(status)) { + ndr_err = ndr_token_retrieve_cmp_fn(&ndr->nbt_string_list, s, &offset, (comparison_fn_t)strcmp, false); + if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { uint8_t b[2]; if (offset > 0x3FFF) { @@ -181,7 +183,7 @@ _PUBLIC_ NTSTATUS ndr_push_nbt_string(struct ndr_push *ndr, int ndr_flags, const (unsigned char)complen, (unsigned char)complen, (unsigned char)complen, s); - NT_STATUS_HAVE_NO_MEMORY(compname); + NDR_ERR_HAVE_NO_MEMORY(compname); /* remember the current componemt + the rest of the string * so it can be reused later @@ -279,7 +281,7 @@ static uint8_t *compress_name(TALLOC_CTX *mem_ctx, /** pull a nbt name from the wire */ -_PUBLIC_ NTSTATUS ndr_pull_nbt_name(struct ndr_pull *ndr, int ndr_flags, struct nbt_name *r) +_PUBLIC_ enum ndr_err_code ndr_pull_nbt_name(struct ndr_pull *ndr, int ndr_flags, struct nbt_name *r) { uint8_t *scope; char *cname; @@ -287,7 +289,7 @@ _PUBLIC_ NTSTATUS ndr_pull_nbt_name(struct ndr_pull *ndr, int ndr_flags, struct bool ok; if (!(ndr_flags & NDR_SCALARS)) { - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } NDR_CHECK(ndr_pull_nbt_string(ndr, ndr_flags, &s)); @@ -296,7 +298,7 @@ _PUBLIC_ NTSTATUS ndr_pull_nbt_name(struct ndr_pull *ndr, int ndr_flags, struct if (scope) { *scope = 0; r->scope = talloc_strdup(ndr->current_mem_ctx, (const char *)&scope[1]); - NT_STATUS_HAVE_NO_MEMORY(r->scope); + NDR_ERR_HAVE_NO_MEMORY(r->scope); } else { r->scope = NULL; } @@ -318,23 +320,23 @@ _PUBLIC_ NTSTATUS ndr_pull_nbt_name(struct ndr_pull *ndr, int ndr_flags, struct } r->name = talloc_strdup(ndr->current_mem_ctx, cname); - NT_STATUS_HAVE_NO_MEMORY(r->name); + NDR_ERR_HAVE_NO_MEMORY(r->name); talloc_free(cname); - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /** push a nbt name to the wire */ -_PUBLIC_ NTSTATUS ndr_push_nbt_name(struct ndr_push *ndr, int ndr_flags, const struct nbt_name *r) +_PUBLIC_ enum ndr_err_code ndr_push_nbt_name(struct ndr_push *ndr, int ndr_flags, const struct nbt_name *r) { uint8_t *cname, *fullname; - NTSTATUS status; + enum ndr_err_code ndr_err; if (!(ndr_flags & NDR_SCALARS)) { - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } if (strlen(r->name) > 15) { @@ -344,19 +346,19 @@ _PUBLIC_ NTSTATUS ndr_push_nbt_name(struct ndr_push *ndr, int ndr_flags, const s } cname = compress_name(ndr, (const uint8_t *)r->name, r->type); - NT_STATUS_HAVE_NO_MEMORY(cname); + NDR_ERR_HAVE_NO_MEMORY(cname); if (r->scope) { fullname = (uint8_t *)talloc_asprintf(ndr, "%s.%s", cname, r->scope); - NT_STATUS_HAVE_NO_MEMORY(fullname); + NDR_ERR_HAVE_NO_MEMORY(fullname); talloc_free(cname); } else { fullname = cname; } - status = ndr_push_nbt_string(ndr, ndr_flags, (const char *)fullname); + ndr_err = ndr_push_nbt_string(ndr, ndr_flags, (const char *)fullname); - return status; + return ndr_err; } @@ -380,18 +382,31 @@ _PUBLIC_ NTSTATUS nbt_name_dup(TALLOC_CTX *mem_ctx, struct nbt_name *name, struc */ _PUBLIC_ NTSTATUS nbt_name_to_blob(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, struct nbt_name *name) { - return ndr_push_struct_blob(blob, mem_ctx, name, - (ndr_push_flags_fn_t)ndr_push_nbt_name); -} + enum ndr_err_code ndr_err; + ndr_err = ndr_push_struct_blob(blob, mem_ctx, name, + (ndr_push_flags_fn_t)ndr_push_nbt_name); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + return ndr_map_error2ntstatus(ndr_err); + } + + return NT_STATUS_OK; +} /** pull a nbt name from a blob */ _PUBLIC_ NTSTATUS nbt_name_from_blob(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, struct nbt_name *name) { - return ndr_pull_struct_blob(blob, mem_ctx, name, - (ndr_pull_flags_fn_t)ndr_pull_nbt_name); + enum ndr_err_code ndr_err; + + ndr_err = ndr_pull_struct_blob(blob, mem_ctx, name, + (ndr_pull_flags_fn_t)ndr_pull_nbt_name); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + return ndr_map_error2ntstatus(ndr_err); + } + + return NT_STATUS_OK; } @@ -485,14 +500,14 @@ _PUBLIC_ char *nbt_name_string(TALLOC_CTX *mem_ctx, const struct nbt_name *name) /** pull a nbt name, WINS Replication uses another on wire format for nbt name */ -_PUBLIC_ NTSTATUS ndr_pull_wrepl_nbt_name(struct ndr_pull *ndr, int ndr_flags, struct nbt_name **_r) +_PUBLIC_ enum ndr_err_code ndr_pull_wrepl_nbt_name(struct ndr_pull *ndr, int ndr_flags, struct nbt_name **_r) { struct nbt_name *r; uint8_t *namebuf; uint32_t namebuf_len; if (!(ndr_flags & NDR_SCALARS)) { - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } NDR_CHECK(ndr_pull_align(ndr, 4)); @@ -521,7 +536,7 @@ _PUBLIC_ NTSTATUS ndr_pull_wrepl_nbt_name(struct ndr_pull *ndr, int ndr_flags, s talloc_free(namebuf); *_r = r; - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } r->type = namebuf[15]; @@ -540,13 +555,13 @@ _PUBLIC_ NTSTATUS ndr_pull_wrepl_nbt_name(struct ndr_pull *ndr, int ndr_flags, s talloc_free(namebuf); *_r = r; - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /** push a nbt name, WINS Replication uses another on wire format for nbt name */ -_PUBLIC_ NTSTATUS ndr_push_wrepl_nbt_name(struct ndr_push *ndr, int ndr_flags, const struct nbt_name *r) +_PUBLIC_ enum ndr_err_code ndr_push_wrepl_nbt_name(struct ndr_push *ndr, int ndr_flags, const struct nbt_name *r) { uint8_t *namebuf; uint32_t namebuf_len; @@ -559,7 +574,7 @@ _PUBLIC_ NTSTATUS ndr_push_wrepl_nbt_name(struct ndr_push *ndr, int ndr_flags, c } if (!(ndr_flags & NDR_SCALARS)) { - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } name_len = strlen(r->name); @@ -602,7 +617,7 @@ _PUBLIC_ NTSTATUS ndr_push_wrepl_nbt_name(struct ndr_push *ndr, int ndr_flags, c NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, namebuf, namebuf_len)); talloc_free(namebuf); - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } _PUBLIC_ void ndr_print_wrepl_nbt_name(struct ndr_print *ndr, const char *name, const struct nbt_name *r) diff --git a/source4/libcli/nbt/nbtsocket.c b/source4/libcli/nbt/nbtsocket.c index 7d88c83044..1f34b4583b 100644 --- a/source4/libcli/nbt/nbtsocket.c +++ b/source4/libcli/nbt/nbtsocket.c @@ -157,6 +157,7 @@ static void nbt_name_socket_recv(struct nbt_name_socket *nbtsock) { TALLOC_CTX *tmp_ctx = talloc_new(nbtsock); NTSTATUS status; + enum ndr_err_code ndr_err; struct socket_address *src; DATA_BLOB blob; size_t nread, dsize; @@ -189,9 +190,10 @@ static void nbt_name_socket_recv(struct nbt_name_socket *nbtsock) } /* parse the request */ - status = ndr_pull_struct_blob(&blob, packet, packet, - (ndr_pull_flags_fn_t)ndr_pull_nbt_name_packet); - if (!NT_STATUS_IS_OK(status)) { + ndr_err = ndr_pull_struct_blob(&blob, packet, packet, + (ndr_pull_flags_fn_t)ndr_pull_nbt_name_packet); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + status = ndr_map_error2ntstatus(ndr_err); DEBUG(2,("Failed to parse incoming NBT name packet - %s\n", nt_errstr(status))); talloc_free(tmp_ctx); @@ -359,7 +361,7 @@ struct nbt_name_request *nbt_name_request_send(struct nbt_name_socket *nbtsock, { struct nbt_name_request *req; int id; - NTSTATUS status; + enum ndr_err_code ndr_err; req = talloc_zero(nbtsock, struct nbt_name_request); if (req == NULL) goto failed; @@ -392,9 +394,9 @@ struct nbt_name_request *nbt_name_request_send(struct nbt_name_socket *nbtsock, talloc_set_destructor(req, nbt_name_request_destructor); - status = ndr_push_struct_blob(&req->encoded, req, request, - (ndr_push_flags_fn_t)ndr_push_nbt_name_packet); - if (!NT_STATUS_IS_OK(status)) goto failed; + ndr_err = ndr_push_struct_blob(&req->encoded, req, request, + (ndr_push_flags_fn_t)ndr_push_nbt_name_packet); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) goto failed; DLIST_ADD_END(nbtsock->send_queue, req, struct nbt_name_request *); @@ -422,7 +424,7 @@ NTSTATUS nbt_name_reply_send(struct nbt_name_socket *nbtsock, struct nbt_name_packet *request) { struct nbt_name_request *req; - NTSTATUS status; + enum ndr_err_code ndr_err; req = talloc_zero(nbtsock, struct nbt_name_request); NT_STATUS_HAVE_NO_MEMORY(req); @@ -439,11 +441,11 @@ NTSTATUS nbt_name_reply_send(struct nbt_name_socket *nbtsock, NDR_PRINT_DEBUG(nbt_name_packet, request); } - status = ndr_push_struct_blob(&req->encoded, req, request, - (ndr_push_flags_fn_t)ndr_push_nbt_name_packet); - if (!NT_STATUS_IS_OK(status)) { + ndr_err = ndr_push_struct_blob(&req->encoded, req, request, + (ndr_push_flags_fn_t)ndr_push_nbt_name_packet); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { talloc_free(req); - return status; + return ndr_map_error2ntstatus(ndr_err); } DLIST_ADD_END(nbtsock->send_queue, req, struct nbt_name_request *); diff --git a/source4/libcli/raw/rawacl.c b/source4/libcli/raw/rawacl.c index 168f9c0309..0f2fdb60af 100644 --- a/source4/libcli/raw/rawacl.c +++ b/source4/libcli/raw/rawacl.c @@ -61,6 +61,7 @@ NTSTATUS smb_raw_query_secdesc_recv(struct smbcli_request *req, NTSTATUS status; struct smb_nttrans nt; struct ndr_pull *ndr; + enum ndr_err_code ndr_err; status = smb_raw_nttrans_recv(req, mem_ctx, &nt); if (!NT_STATUS_IS_OK(status)) { @@ -84,10 +85,13 @@ NTSTATUS smb_raw_query_secdesc_recv(struct smbcli_request *req, if (!io->query_secdesc.out.sd) { return NT_STATUS_NO_MEMORY; } - status = ndr_pull_security_descriptor(ndr, NDR_SCALARS|NDR_BUFFERS, - io->query_secdesc.out.sd); + ndr_err = ndr_pull_security_descriptor(ndr, NDR_SCALARS|NDR_BUFFERS, + io->query_secdesc.out.sd); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + return ndr_map_error2ntstatus(ndr_err); + } - return status; + return NT_STATUS_OK; } @@ -114,7 +118,7 @@ struct smbcli_request *smb_raw_set_secdesc_send(struct smbcli_tree *tree, uint8_t params[8]; struct ndr_push *ndr; struct smbcli_request *req; - NTSTATUS status; + enum ndr_err_code ndr_err; nt.in.max_setup = 0; nt.in.max_param = 0; @@ -133,8 +137,8 @@ struct smbcli_request *smb_raw_set_secdesc_send(struct smbcli_tree *tree, ndr = ndr_push_init_ctx(NULL); if (!ndr) return NULL; - status = ndr_push_security_descriptor(ndr, NDR_SCALARS|NDR_BUFFERS, io->set_secdesc.in.sd); - if (!NT_STATUS_IS_OK(status)) { + ndr_err = ndr_push_security_descriptor(ndr, NDR_SCALARS|NDR_BUFFERS, io->set_secdesc.in.sd); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { talloc_free(ndr); return NULL; } diff --git a/source4/libcli/raw/rawfile.c b/source4/libcli/raw/rawfile.c index 83303cf470..c34cb9c52f 100644 --- a/source4/libcli/raw/rawfile.c +++ b/source4/libcli/raw/rawfile.c @@ -263,7 +263,6 @@ static struct smbcli_request *smb_raw_nttrans_create_send(struct smbcli_tree *tr uint16_t fname_len; DATA_BLOB sd_blob, ea_blob; struct smbcli_request *req; - NTSTATUS status; nt.in.max_setup = 0; nt.in.max_param = 101; @@ -276,10 +275,11 @@ static struct smbcli_request *smb_raw_nttrans_create_send(struct smbcli_tree *tr ea_blob = data_blob(NULL, 0); if (parms->ntcreatex.in.sec_desc) { - status = ndr_push_struct_blob(&sd_blob, mem_ctx, - parms->ntcreatex.in.sec_desc, - (ndr_push_flags_fn_t)ndr_push_security_descriptor); - if (!NT_STATUS_IS_OK(status)) { + enum ndr_err_code ndr_err; + ndr_err = ndr_push_struct_blob(&sd_blob, mem_ctx, + parms->ntcreatex.in.sec_desc, + (ndr_push_flags_fn_t)ndr_push_security_descriptor); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { talloc_free(mem_ctx); return NULL; } diff --git a/source4/libcli/raw/rawfileinfo.c b/source4/libcli/raw/rawfileinfo.c index 8481995c1a..17e1792fe3 100644 --- a/source4/libcli/raw/rawfileinfo.c +++ b/source4/libcli/raw/rawfileinfo.c @@ -245,15 +245,17 @@ NTSTATUS smb_raw_fileinfo_passthru_parse(const DATA_BLOB *blob, TALLOC_CTX *mem_ return NT_STATUS_OK; case RAW_FILEINFO_SEC_DESC: { - NTSTATUS status; + enum ndr_err_code ndr_err; parms->query_secdesc.out.sd = talloc(mem_ctx, struct security_descriptor); NT_STATUS_HAVE_NO_MEMORY(parms->query_secdesc.out.sd); - status = ndr_pull_struct_blob(blob, mem_ctx, - parms->query_secdesc.out.sd, - (ndr_pull_flags_fn_t)ndr_pull_security_descriptor); - NT_STATUS_NOT_OK_RETURN(status); + ndr_err = ndr_pull_struct_blob(blob, mem_ctx, + parms->query_secdesc.out.sd, + (ndr_pull_flags_fn_t)ndr_pull_security_descriptor); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + return ndr_map_error2ntstatus(ndr_err); + } return NT_STATUS_OK; } diff --git a/source4/libcli/raw/rawfsinfo.c b/source4/libcli/raw/rawfsinfo.c index ced977333d..73f1192df0 100644 --- a/source4/libcli/raw/rawfsinfo.c +++ b/source4/libcli/raw/rawfsinfo.c @@ -158,6 +158,7 @@ NTSTATUS smb_raw_fsinfo_passthru_parse(DATA_BLOB blob, TALLOC_CTX *mem_ctx, union smb_fsinfo *fsinfo) { NTSTATUS status = NT_STATUS_OK; + enum ndr_err_code ndr_err; int i; /* parse the results */ @@ -215,8 +216,11 @@ NTSTATUS smb_raw_fsinfo_passthru_parse(DATA_BLOB blob, TALLOC_CTX *mem_ctx, case RAW_QFS_OBJECTID_INFORMATION: QFS_CHECK_SIZE(64); - status = ndr_pull_struct_blob(&blob, mem_ctx, &fsinfo->objectid_information.out.guid, - (ndr_pull_flags_fn_t)ndr_pull_GUID); + ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, &fsinfo->objectid_information.out.guid, + (ndr_pull_flags_fn_t)ndr_pull_GUID); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + status = ndr_map_error2ntstatus(ndr_err); + } for (i=0;i<6;i++) { fsinfo->objectid_information.out.unknown[i] = BVAL(blob.data, 16 + i*8); } diff --git a/source4/libcli/raw/rawsetfileinfo.c b/source4/libcli/raw/rawsetfileinfo.c index 5fa0c1f2da..3ae2a2dd20 100644 --- a/source4/libcli/raw/rawsetfileinfo.c +++ b/source4/libcli/raw/rawsetfileinfo.c @@ -86,12 +86,14 @@ bool smb_raw_setfileinfo_passthru(TALLOC_CTX *mem_ctx, return true; case RAW_FILEINFO_SEC_DESC: { - NTSTATUS status; - - status = ndr_push_struct_blob(blob, mem_ctx, - parms->set_secdesc.in.sd, - (ndr_push_flags_fn_t)ndr_push_security_descriptor); - if (!NT_STATUS_IS_OK(status)) return false; + enum ndr_err_code ndr_err; + + ndr_err = ndr_push_struct_blob(blob, mem_ctx, + parms->set_secdesc.in.sd, + (ndr_push_flags_fn_t)ndr_push_security_descriptor); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + return false; + } return true; } diff --git a/source4/libcli/wrepl/winsrepl.c b/source4/libcli/wrepl/winsrepl.c index 29cc1f37fd..1f7ca796b6 100644 --- a/source4/libcli/wrepl/winsrepl.c +++ b/source4/libcli/wrepl/winsrepl.c @@ -85,7 +85,7 @@ static NTSTATUS wrepl_finish_recv(void *private, DATA_BLOB packet_blob_in) struct wrepl_socket *wrepl_socket = talloc_get_type(private, struct wrepl_socket); struct wrepl_request *req = wrepl_socket->recv_queue; DATA_BLOB blob; - NTSTATUS status; + enum ndr_err_code ndr_err; if (!req) { DEBUG(1,("Received unexpected WINS packet of length %u!\n", @@ -100,10 +100,11 @@ static NTSTATUS wrepl_finish_recv(void *private, DATA_BLOB packet_blob_in) blob.length = packet_blob_in.length - 4; /* we have a full request - parse it */ - status = ndr_pull_struct_blob(&blob, - req->packet, req->packet, - (ndr_pull_flags_fn_t)ndr_pull_wrepl_packet); - if (!NT_STATUS_IS_OK(status)) { + ndr_err = ndr_pull_struct_blob(&blob, + req->packet, req->packet, + (ndr_pull_flags_fn_t)ndr_pull_wrepl_packet); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + NTSTATUS status = ndr_map_error2ntstatus(ndr_err); wrepl_request_finished(req, status); return NT_STATUS_OK; } @@ -470,6 +471,7 @@ struct wrepl_request *wrepl_request_send(struct wrepl_socket *wrepl_socket, struct wrepl_wrap wrap; DATA_BLOB blob; NTSTATUS status; + enum ndr_err_code ndr_err; req = talloc_zero(wrepl_socket, struct wrepl_request); if (!req) return NULL; @@ -485,9 +487,10 @@ struct wrepl_request *wrepl_request_send(struct wrepl_socket *wrepl_socket, } wrap.packet = *packet; - status = ndr_push_struct_blob(&blob, req, &wrap, - (ndr_push_flags_fn_t)ndr_push_wrepl_wrap); - if (!NT_STATUS_IS_OK(status)) { + ndr_err = ndr_push_struct_blob(&blob, req, &wrap, + (ndr_push_flags_fn_t)ndr_push_wrepl_wrap); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + status = ndr_map_error2ntstatus(ndr_err); return wrepl_request_finished(req, status); } -- cgit