summaryrefslogtreecommitdiff
path: root/source4/ntvfs
diff options
context:
space:
mode:
Diffstat (limited to 'source4/ntvfs')
-rw-r--r--source4/ntvfs/common/notify.c32
-rw-r--r--source4/ntvfs/common/opendb_tdb.c20
-rw-r--r--source4/ntvfs/ipc/ipc_rap.c136
-rw-r--r--source4/ntvfs/posix/pvfs_xattr.c15
4 files changed, 128 insertions, 75 deletions
diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c
index 0214c39b2d..4578dfbf10 100644
--- a/source4/ntvfs/common/notify.c
+++ b/source4/ntvfs/common/notify.c
@@ -146,7 +146,7 @@ static NTSTATUS notify_load(struct notify_context *notify)
{
TDB_DATA dbuf;
DATA_BLOB blob;
- NTSTATUS status;
+ enum ndr_err_code ndr_err;
int seqnum;
seqnum = tdb_get_seqnum(notify->w->tdb);
@@ -169,11 +169,14 @@ static NTSTATUS notify_load(struct notify_context *notify)
blob.data = dbuf.dptr;
blob.length = dbuf.dsize;
- status = ndr_pull_struct_blob(&blob, notify->array, notify->array,
- (ndr_pull_flags_fn_t)ndr_pull_notify_array);
+ ndr_err = ndr_pull_struct_blob(&blob, notify->array, notify->array,
+ (ndr_pull_flags_fn_t)ndr_pull_notify_array);
free(dbuf.dptr);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ return ndr_map_error2ntstatus(ndr_err);
+ }
- return status;
+ return NT_STATUS_OK;
}
/*
@@ -192,7 +195,7 @@ static NTSTATUS notify_save(struct notify_context *notify)
{
TDB_DATA dbuf;
DATA_BLOB blob;
- NTSTATUS status;
+ enum ndr_err_code ndr_err;
int ret;
TALLOC_CTX *tmp_ctx;
@@ -214,11 +217,11 @@ static NTSTATUS notify_save(struct notify_context *notify)
tmp_ctx = talloc_new(notify);
NT_STATUS_HAVE_NO_MEMORY(tmp_ctx);
- status = ndr_push_struct_blob(&blob, tmp_ctx, notify->array,
- (ndr_push_flags_fn_t)ndr_push_notify_array);
- if (!NT_STATUS_IS_OK(status)) {
+ ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, notify->array,
+ (ndr_push_flags_fn_t)ndr_push_notify_array);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
talloc_free(tmp_ctx);
- return status;
+ return ndr_map_error2ntstatus(ndr_err);
}
dbuf.dptr = blob.data;
@@ -241,7 +244,7 @@ static void notify_handler(struct messaging_context *msg_ctx, void *private_data
uint32_t msg_type, struct server_id server_id, DATA_BLOB *data)
{
struct notify_context *notify = talloc_get_type(private_data, struct notify_context);
- NTSTATUS status;
+ enum ndr_err_code ndr_err;
struct notify_event ev;
TALLOC_CTX *tmp_ctx = talloc_new(notify);
struct notify_list *listel;
@@ -250,9 +253,9 @@ static void notify_handler(struct messaging_context *msg_ctx, void *private_data
return;
}
- status = ndr_pull_struct_blob(data, tmp_ctx, &ev,
+ ndr_err = ndr_pull_struct_blob(data, tmp_ctx, &ev,
(ndr_pull_flags_fn_t)ndr_pull_notify_event);
- if (!NT_STATUS_IS_OK(status)) {
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
talloc_free(tmp_ctx);
return;
}
@@ -540,6 +543,7 @@ static void notify_send(struct notify_context *notify, struct notify_entry *e,
struct notify_event ev;
DATA_BLOB data;
NTSTATUS status;
+ enum ndr_err_code ndr_err;
TALLOC_CTX *tmp_ctx;
ev.action = action;
@@ -548,9 +552,9 @@ static void notify_send(struct notify_context *notify, struct notify_entry *e,
tmp_ctx = talloc_new(notify);
- status = ndr_push_struct_blob(&data, tmp_ctx, &ev,
+ ndr_err = ndr_push_struct_blob(&data, tmp_ctx, &ev,
(ndr_push_flags_fn_t)ndr_push_notify_event);
- if (!NT_STATUS_IS_OK(status)) {
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
talloc_free(tmp_ctx);
return;
}
diff --git a/source4/ntvfs/common/opendb_tdb.c b/source4/ntvfs/common/opendb_tdb.c
index a037e7e47e..07eef829e1 100644
--- a/source4/ntvfs/common/opendb_tdb.c
+++ b/source4/ntvfs/common/opendb_tdb.c
@@ -195,8 +195,8 @@ static NTSTATUS odb_pull_record(struct odb_lock *lck, struct opendb_file *file)
struct odb_context *odb = lck->odb;
TDB_DATA dbuf;
DATA_BLOB blob;
- NTSTATUS status;
-
+ enum ndr_err_code ndr_err;
+
dbuf = tdb_fetch(odb->w->tdb, lck->key);
if (dbuf.dptr == NULL) {
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
@@ -205,11 +205,13 @@ static NTSTATUS odb_pull_record(struct odb_lock *lck, struct opendb_file *file)
blob.data = dbuf.dptr;
blob.length = dbuf.dsize;
- status = ndr_pull_struct_blob(&blob, lck, file, (ndr_pull_flags_fn_t)ndr_pull_opendb_file);
-
+ ndr_err = ndr_pull_struct_blob(&blob, lck, file, (ndr_pull_flags_fn_t)ndr_pull_opendb_file);
free(dbuf.dptr);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ return ndr_map_error2ntstatus(ndr_err);
+ }
- return status;
+ return NT_STATUS_OK;
}
/*
@@ -220,7 +222,7 @@ static NTSTATUS odb_push_record(struct odb_lock *lck, struct opendb_file *file)
struct odb_context *odb = lck->odb;
TDB_DATA dbuf;
DATA_BLOB blob;
- NTSTATUS status;
+ enum ndr_err_code ndr_err;
int ret;
if (file->num_entries == 0) {
@@ -231,8 +233,10 @@ static NTSTATUS odb_push_record(struct odb_lock *lck, struct opendb_file *file)
return NT_STATUS_OK;
}
- status = ndr_push_struct_blob(&blob, lck, file, (ndr_push_flags_fn_t)ndr_push_opendb_file);
- NT_STATUS_NOT_OK_RETURN(status);
+ ndr_err = ndr_push_struct_blob(&blob, lck, file, (ndr_push_flags_fn_t)ndr_push_opendb_file);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ return ndr_map_error2ntstatus(ndr_err);
+ }
dbuf.dptr = blob.data;
dbuf.dsize = blob.length;
diff --git a/source4/ntvfs/ipc/ipc_rap.c b/source4/ntvfs/ipc/ipc_rap.c
index 605a172a70..2a9d66cae8 100644
--- a/source4/ntvfs/ipc/ipc_rap.c
+++ b/source4/ntvfs/ipc/ipc_rap.c
@@ -24,6 +24,33 @@
#include "ntvfs/ipc/proto.h"
#include "librpc/ndr/libndr.h"
+#define NDR_RETURN(call) do { \
+ enum ndr_err_code _ndr_err; \
+ _ndr_err = call; \
+ if (!NDR_ERR_CODE_IS_SUCCESS(_ndr_err)) { \
+ return ndr_map_error2ntstatus(_ndr_err); \
+ } \
+} while (0)
+
+#define RAP_GOTO(call) do { \
+ result = call; \
+ if (NT_STATUS_EQUAL(result, NT_STATUS_BUFFER_TOO_SMALL)) {\
+ goto buffer_overflow; \
+ } \
+ if (!NT_STATUS_IS_OK(result)) { \
+ goto done; \
+ } \
+} while (0)
+
+#define NDR_GOTO(call) do { \
+ enum ndr_err_code _ndr_err; \
+ _ndr_err = call; \
+ if (!NDR_ERR_CODE_IS_SUCCESS(_ndr_err)) { \
+ RAP_GOTO(ndr_map_error2ntstatus(_ndr_err)); \
+ } \
+} while (0)
+
+
#define NERR_Success 0
#define NERR_badpass 86
#define NERR_notsupported 50
@@ -108,22 +135,37 @@ static struct rap_call *new_rap_srv_call(TALLOC_CTX *mem_ctx,
static NTSTATUS rap_srv_pull_word(struct rap_call *call, uint16_t *result)
{
+ enum ndr_err_code ndr_err;
+
if (*call->paramdesc++ != 'W')
return NT_STATUS_INVALID_PARAMETER;
- return ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, result);
+ ndr_err = ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, result);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ return ndr_map_error2ntstatus(ndr_err);
+ }
+
+ return NT_STATUS_OK;
}
static NTSTATUS rap_srv_pull_dword(struct rap_call *call, uint32_t *result)
{
+ enum ndr_err_code ndr_err;
+
if (*call->paramdesc++ != 'D')
return NT_STATUS_INVALID_PARAMETER;
- return ndr_pull_uint32(call->ndr_pull_param, NDR_SCALARS, result);
+ ndr_err = ndr_pull_uint32(call->ndr_pull_param, NDR_SCALARS, result);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ return ndr_map_error2ntstatus(ndr_err);
+ }
+
+ return NT_STATUS_OK;
}
static NTSTATUS rap_srv_pull_string(struct rap_call *call, const char **result)
{
+ enum ndr_err_code ndr_err;
char paramdesc = *call->paramdesc++;
if (paramdesc == 'O') {
@@ -134,20 +176,25 @@ static NTSTATUS rap_srv_pull_string(struct rap_call *call, const char **result)
if (paramdesc != 'z')
return NT_STATUS_INVALID_PARAMETER;
- return ndr_pull_string(call->ndr_pull_param, NDR_SCALARS, result);
+ ndr_err = ndr_pull_string(call->ndr_pull_param, NDR_SCALARS, result);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ return ndr_map_error2ntstatus(ndr_err);
+ }
+
+ return NT_STATUS_OK;
}
static NTSTATUS rap_srv_pull_bufsize(struct rap_call *call, uint16_t *bufsize)
{
- NTSTATUS result;
+ enum ndr_err_code ndr_err;
if ( (*call->paramdesc++ != 'r') || (*call->paramdesc++ != 'L') )
return NT_STATUS_INVALID_PARAMETER;
- result = ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, bufsize);
-
- if (!NT_STATUS_IS_OK(result))
- return result;
+ ndr_err = ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, bufsize);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ return ndr_map_error2ntstatus(ndr_err);
+ }
call->heap->offset = *bufsize;
@@ -178,8 +225,8 @@ static NTSTATUS rap_push_string(struct ndr_push *data_push,
heap->offset -= space;
- NDR_CHECK(ndr_push_uint16(data_push, NDR_SCALARS, heap->offset));
- NDR_CHECK(ndr_push_uint16(data_push, NDR_SCALARS, 0));
+ NDR_RETURN(ndr_push_uint16(data_push, NDR_SCALARS, heap->offset));
+ NDR_RETURN(ndr_push_uint16(data_push, NDR_SCALARS, 0));
heap->strings = talloc_realloc(heap->mem_ctx,
heap->strings,
@@ -195,21 +242,14 @@ static NTSTATUS rap_push_string(struct ndr_push *data_push,
return NT_STATUS_OK;
}
-#define NDR_OK(call) do { result = call; \
- if (NT_STATUS_EQUAL(result, NT_STATUS_BUFFER_TOO_SMALL)) \
- goto buffer_overflow; \
- if (!NT_STATUS_IS_OK(result)) \
- goto done; \
- } while (0)
-
static NTSTATUS _rap_netshareenum(struct rap_call *call)
{
struct rap_NetShareEnum r;
NTSTATUS result;
- NDR_OK(rap_srv_pull_word(call, &r.in.level));
- NDR_OK(rap_srv_pull_bufsize(call, &r.in.bufsize));
- NDR_OK(rap_srv_pull_expect_multiple(call));
+ RAP_GOTO(rap_srv_pull_word(call, &r.in.level));
+ RAP_GOTO(rap_srv_pull_bufsize(call, &r.in.bufsize));
+ RAP_GOTO(rap_srv_pull_expect_multiple(call));
switch(r.in.level) {
case 0:
@@ -241,20 +281,20 @@ static NTSTATUS _rap_netshareenum(struct rap_call *call)
switch(r.in.level) {
case 0:
- NDR_OK(ndr_push_bytes(call->ndr_push_data,
+ NDR_GOTO(ndr_push_bytes(call->ndr_push_data,
(const uint8_t *)r.out.info[i].info0.name,
sizeof(r.out.info[i].info0.name)));
break;
case 1:
- NDR_OK(ndr_push_bytes(call->ndr_push_data,
+ NDR_GOTO(ndr_push_bytes(call->ndr_push_data,
(const uint8_t *)r.out.info[i].info1.name,
sizeof(r.out.info[i].info1.name)));
- NDR_OK(ndr_push_uint8(call->ndr_push_data,
+ NDR_GOTO(ndr_push_uint8(call->ndr_push_data,
NDR_SCALARS, r.out.info[i].info1.pad));
- NDR_OK(ndr_push_uint16(call->ndr_push_data,
+ NDR_GOTO(ndr_push_uint16(call->ndr_push_data,
NDR_SCALARS, r.out.info[i].info1.type));
- NDR_OK(rap_push_string(call->ndr_push_data,
+ RAP_GOTO(rap_push_string(call->ndr_push_data,
call->heap,
r.out.info[i].info1.comment));
@@ -273,8 +313,8 @@ static NTSTATUS _rap_netshareenum(struct rap_call *call)
call->status = r.out.status;
- NDR_CHECK(ndr_push_uint16(call->ndr_push_param, NDR_SCALARS, r.out.count));
- NDR_CHECK(ndr_push_uint16(call->ndr_push_param, NDR_SCALARS, r.out.available));
+ NDR_RETURN(ndr_push_uint16(call->ndr_push_param, NDR_SCALARS, r.out.count));
+ NDR_RETURN(ndr_push_uint16(call->ndr_push_param, NDR_SCALARS, r.out.available));
result = NT_STATUS_OK;
@@ -287,11 +327,11 @@ static NTSTATUS _rap_netserverenum2(struct rap_call *call)
struct rap_NetServerEnum2 r;
NTSTATUS result;
- NDR_OK(rap_srv_pull_word(call, &r.in.level));
- NDR_OK(rap_srv_pull_bufsize(call, &r.in.bufsize));
- NDR_OK(rap_srv_pull_expect_multiple(call));
- NDR_OK(rap_srv_pull_dword(call, &r.in.servertype));
- NDR_OK(rap_srv_pull_string(call, &r.in.domain));
+ RAP_GOTO(rap_srv_pull_word(call, &r.in.level));
+ RAP_GOTO(rap_srv_pull_bufsize(call, &r.in.bufsize));
+ RAP_GOTO(rap_srv_pull_expect_multiple(call));
+ RAP_GOTO(rap_srv_pull_dword(call, &r.in.servertype));
+ RAP_GOTO(rap_srv_pull_string(call, &r.in.domain));
switch(r.in.level) {
case 0:
@@ -323,22 +363,22 @@ static NTSTATUS _rap_netserverenum2(struct rap_call *call)
switch(r.in.level) {
case 0:
- NDR_OK(ndr_push_bytes(call->ndr_push_data,
+ NDR_GOTO(ndr_push_bytes(call->ndr_push_data,
(const uint8_t *)r.out.info[i].info0.name,
sizeof(r.out.info[i].info0.name)));
break;
case 1:
- NDR_OK(ndr_push_bytes(call->ndr_push_data,
+ NDR_GOTO(ndr_push_bytes(call->ndr_push_data,
(const uint8_t *)r.out.info[i].info1.name,
sizeof(r.out.info[i].info1.name)));
- NDR_OK(ndr_push_uint8(call->ndr_push_data,
+ NDR_GOTO(ndr_push_uint8(call->ndr_push_data,
NDR_SCALARS, r.out.info[i].info1.version_major));
- NDR_OK(ndr_push_uint8(call->ndr_push_data,
+ NDR_GOTO(ndr_push_uint8(call->ndr_push_data,
NDR_SCALARS, r.out.info[i].info1.version_minor));
- NDR_OK(ndr_push_uint32(call->ndr_push_data,
+ NDR_GOTO(ndr_push_uint32(call->ndr_push_data,
NDR_SCALARS, r.out.info[i].info1.servertype));
- NDR_OK(rap_push_string(call->ndr_push_data,
+ RAP_GOTO(rap_push_string(call->ndr_push_data,
call->heap,
r.out.info[i].info1.comment));
@@ -357,8 +397,8 @@ static NTSTATUS _rap_netserverenum2(struct rap_call *call)
call->status = r.out.status;
- NDR_CHECK(ndr_push_uint16(call->ndr_push_param, NDR_SCALARS, r.out.count));
- NDR_CHECK(ndr_push_uint16(call->ndr_push_param, NDR_SCALARS, r.out.available));
+ NDR_RETURN(ndr_push_uint16(call->ndr_push_param, NDR_SCALARS, r.out.count));
+ NDR_RETURN(ndr_push_uint16(call->ndr_push_param, NDR_SCALARS, r.out.available));
result = NT_STATUS_OK;
@@ -398,10 +438,10 @@ NTSTATUS ipc_rap_call(TALLOC_CTX *mem_ctx, struct smb_trans2 *trans)
if (call == NULL)
return NT_STATUS_NO_MEMORY;
- NDR_CHECK(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &call->callno));
- NDR_CHECK(ndr_pull_string(call->ndr_pull_param, NDR_SCALARS,
+ NDR_RETURN(ndr_pull_uint16(call->ndr_pull_param, NDR_SCALARS, &call->callno));
+ NDR_RETURN(ndr_pull_string(call->ndr_pull_param, NDR_SCALARS,
&call->paramdesc));
- NDR_CHECK(ndr_pull_string(call->ndr_pull_param, NDR_SCALARS,
+ NDR_RETURN(ndr_pull_string(call->ndr_pull_param, NDR_SCALARS,
&call->datadesc));
call->ndr_push_param = ndr_push_init_ctx(call);
@@ -439,17 +479,17 @@ NTSTATUS ipc_rap_call(TALLOC_CTX *mem_ctx, struct smb_trans2 *trans)
final_param->flags = RAPNDR_FLAGS;
final_data->flags = RAPNDR_FLAGS;
- NDR_CHECK(ndr_push_uint16(final_param, NDR_SCALARS, call->status));
- NDR_CHECK(ndr_push_uint16(final_param,
+ NDR_RETURN(ndr_push_uint16(final_param, NDR_SCALARS, call->status));
+ NDR_RETURN(ndr_push_uint16(final_param,
NDR_SCALARS, call->heap->offset - result_data.length));
- NDR_CHECK(ndr_push_bytes(final_param, result_param.data,
+ NDR_RETURN(ndr_push_bytes(final_param, result_param.data,
result_param.length));
- NDR_CHECK(ndr_push_bytes(final_data, result_data.data,
+ NDR_RETURN(ndr_push_bytes(final_data, result_data.data,
result_data.length));
for (i=call->heap->num_strings-1; i>=0; i--)
- NDR_CHECK(ndr_push_string(final_data, NDR_SCALARS,
+ NDR_RETURN(ndr_push_string(final_data, NDR_SCALARS,
call->heap->strings[i]));
trans->out.setup_count = 0;
diff --git a/source4/ntvfs/posix/pvfs_xattr.c b/source4/ntvfs/posix/pvfs_xattr.c
index ead3585e0d..f723aad955 100644
--- a/source4/ntvfs/posix/pvfs_xattr.c
+++ b/source4/ntvfs/posix/pvfs_xattr.c
@@ -107,6 +107,7 @@ _PUBLIC_ NTSTATUS pvfs_xattr_ndr_load(struct pvfs_state *pvfs,
{
NTSTATUS status;
DATA_BLOB blob;
+ enum ndr_err_code ndr_err;
status = pull_xattr_blob(pvfs, mem_ctx, attr_name, fname,
fd, XATTR_DOSATTRIB_ESTIMATED_SIZE, &blob);
@@ -115,11 +116,14 @@ _PUBLIC_ NTSTATUS pvfs_xattr_ndr_load(struct pvfs_state *pvfs,
}
/* pull the blob */
- status = ndr_pull_struct_blob(&blob, mem_ctx, p, (ndr_pull_flags_fn_t)pull_fn);
+ ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, p, (ndr_pull_flags_fn_t)pull_fn);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ return ndr_map_error2ntstatus(ndr_err);
+ }
data_blob_free(&blob);
- return status;
+ return NT_STATUS_OK;
}
/*
@@ -132,11 +136,12 @@ _PUBLIC_ NTSTATUS pvfs_xattr_ndr_save(struct pvfs_state *pvfs,
TALLOC_CTX *mem_ctx = talloc_new(NULL);
DATA_BLOB blob;
NTSTATUS status;
+ enum ndr_err_code ndr_err;
- status = ndr_push_struct_blob(&blob, mem_ctx, p, (ndr_push_flags_fn_t)push_fn);
- if (!NT_STATUS_IS_OK(status)) {
+ ndr_err = ndr_push_struct_blob(&blob, mem_ctx, p, (ndr_push_flags_fn_t)push_fn);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
talloc_free(mem_ctx);
- return status;
+ return ndr_map_error2ntstatus(ndr_err);
}
status = push_xattr_blob(pvfs, attr_name, fname, fd, &blob);