mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
libndr: Return enum ndr_err_code from ndr_{pull,push}_steal_switch_value()
This breaks the ABI so we merge this into the unreleased libndr-1.0.0. The advantage of the new functions is there (except for print, which is unchanged) is an error raised when the token is not found, so we can be confident in the changes to the token behaviour. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13876 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Thu Dec 12 03:56:23 UTC 2019 on sn-devel-184
This commit is contained in:
parent
d30c377d8c
commit
82aff583b7
@ -138,7 +138,7 @@ ndr_pull_restore_relative_base_offset: void (struct ndr_pull *, uint32_t)
|
|||||||
ndr_pull_set_switch_value: enum ndr_err_code (struct ndr_pull *, const void *, uint32_t)
|
ndr_pull_set_switch_value: enum ndr_err_code (struct ndr_pull *, const void *, uint32_t)
|
||||||
ndr_pull_setup_relative_base_offset1: enum ndr_err_code (struct ndr_pull *, const void *, uint32_t)
|
ndr_pull_setup_relative_base_offset1: enum ndr_err_code (struct ndr_pull *, const void *, uint32_t)
|
||||||
ndr_pull_setup_relative_base_offset2: enum ndr_err_code (struct ndr_pull *, const void *)
|
ndr_pull_setup_relative_base_offset2: enum ndr_err_code (struct ndr_pull *, const void *)
|
||||||
ndr_pull_steal_switch_value: uint32_t (struct ndr_pull *, const void *)
|
ndr_pull_steal_switch_value: enum ndr_err_code (struct ndr_pull *, const void *, uint32_t *)
|
||||||
ndr_pull_string: enum ndr_err_code (struct ndr_pull *, int, const char **)
|
ndr_pull_string: enum ndr_err_code (struct ndr_pull *, int, const char **)
|
||||||
ndr_pull_string_array: enum ndr_err_code (struct ndr_pull *, int, const char ***)
|
ndr_pull_string_array: enum ndr_err_code (struct ndr_pull *, int, const char ***)
|
||||||
ndr_pull_struct_blob: enum ndr_err_code (const DATA_BLOB *, TALLOC_CTX *, void *, ndr_pull_flags_fn_t)
|
ndr_pull_struct_blob: enum ndr_err_code (const DATA_BLOB *, TALLOC_CTX *, void *, ndr_pull_flags_fn_t)
|
||||||
@ -213,7 +213,7 @@ ndr_push_setup_relative_base_offset1: enum ndr_err_code (struct ndr_push *, cons
|
|||||||
ndr_push_setup_relative_base_offset2: enum ndr_err_code (struct ndr_push *, const void *)
|
ndr_push_setup_relative_base_offset2: enum ndr_err_code (struct ndr_push *, const void *)
|
||||||
ndr_push_short_relative_ptr1: enum ndr_err_code (struct ndr_push *, const void *)
|
ndr_push_short_relative_ptr1: enum ndr_err_code (struct ndr_push *, const void *)
|
||||||
ndr_push_short_relative_ptr2: enum ndr_err_code (struct ndr_push *, const void *)
|
ndr_push_short_relative_ptr2: enum ndr_err_code (struct ndr_push *, const void *)
|
||||||
ndr_push_steal_switch_value: uint32_t (struct ndr_push *, const void *)
|
ndr_push_steal_switch_value: enum ndr_err_code (struct ndr_push *, const void *, uint32_t *)
|
||||||
ndr_push_string: enum ndr_err_code (struct ndr_push *, int, const char *)
|
ndr_push_string: enum ndr_err_code (struct ndr_push *, int, const char *)
|
||||||
ndr_push_string_array: enum ndr_err_code (struct ndr_push *, int, const char **)
|
ndr_push_string_array: enum ndr_err_code (struct ndr_push *, int, const char **)
|
||||||
ndr_push_struct_blob: enum ndr_err_code (DATA_BLOB *, TALLOC_CTX *, const void *, ndr_push_flags_fn_t)
|
ndr_push_struct_blob: enum ndr_err_code (DATA_BLOB *, TALLOC_CTX *, const void *, ndr_push_flags_fn_t)
|
||||||
|
@ -616,9 +616,16 @@ enum ndr_err_code ndr_check_pipe_chunk_trailer(struct ndr_pull *ndr, int ndr_fla
|
|||||||
enum ndr_err_code ndr_push_set_switch_value(struct ndr_push *ndr, const void *p, uint32_t val);
|
enum ndr_err_code ndr_push_set_switch_value(struct ndr_push *ndr, const void *p, uint32_t val);
|
||||||
enum ndr_err_code ndr_pull_set_switch_value(struct ndr_pull *ndr, const void *p, uint32_t val);
|
enum ndr_err_code ndr_pull_set_switch_value(struct ndr_pull *ndr, const void *p, uint32_t val);
|
||||||
enum ndr_err_code ndr_print_set_switch_value(struct ndr_print *ndr, const void *p, uint32_t val);
|
enum ndr_err_code ndr_print_set_switch_value(struct ndr_print *ndr, const void *p, uint32_t val);
|
||||||
uint32_t ndr_push_steal_switch_value(struct ndr_push *ndr, const void *p);
|
/* retrieve a switch value (for push) and remove it from the list */
|
||||||
|
enum ndr_err_code ndr_push_steal_switch_value(struct ndr_push *ndr,
|
||||||
|
const void *p,
|
||||||
|
uint32_t *v);
|
||||||
|
/* retrieve a switch value and remove it from the list */
|
||||||
uint32_t ndr_print_steal_switch_value(struct ndr_print *ndr, const void *p);
|
uint32_t ndr_print_steal_switch_value(struct ndr_print *ndr, const void *p);
|
||||||
uint32_t ndr_pull_steal_switch_value(struct ndr_pull *ndr, const void *p);
|
/* retrieve a switch value and remove it from the list */
|
||||||
|
enum ndr_err_code ndr_pull_steal_switch_value(struct ndr_pull *ndr,
|
||||||
|
const void *p,
|
||||||
|
uint32_t *v);
|
||||||
enum ndr_err_code ndr_pull_struct_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p, ndr_pull_flags_fn_t fn);
|
enum ndr_err_code ndr_pull_struct_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p, ndr_pull_flags_fn_t fn);
|
||||||
enum ndr_err_code ndr_pull_struct_blob_all(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p, ndr_pull_flags_fn_t fn);
|
enum ndr_err_code ndr_pull_struct_blob_all(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p, ndr_pull_flags_fn_t fn);
|
||||||
enum ndr_err_code ndr_pull_struct_blob_all_noalloc(const DATA_BLOB *blob,
|
enum ndr_err_code ndr_pull_struct_blob_all_noalloc(const DATA_BLOB *blob,
|
||||||
|
@ -1231,17 +1231,11 @@ _PUBLIC_ enum ndr_err_code ndr_print_set_switch_value(struct ndr_print *ndr, con
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* retrieve a switch value (for push) and remove it from the list */
|
/* retrieve a switch value (for push) and remove it from the list */
|
||||||
_PUBLIC_ uint32_t ndr_push_steal_switch_value(struct ndr_push *ndr, const void *p)
|
_PUBLIC_ enum ndr_err_code ndr_push_steal_switch_value(struct ndr_push *ndr,
|
||||||
|
const void *p,
|
||||||
|
uint32_t *v)
|
||||||
{
|
{
|
||||||
enum ndr_err_code status;
|
return ndr_token_retrieve(&ndr->switch_list, p, v);
|
||||||
uint32_t v;
|
|
||||||
|
|
||||||
status = ndr_token_retrieve(&ndr->switch_list, p, &v);
|
|
||||||
if (!NDR_ERR_CODE_IS_SUCCESS(status)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return v;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* retrieve a switch value and remove it from the list */
|
/* retrieve a switch value and remove it from the list */
|
||||||
@ -1259,17 +1253,11 @@ _PUBLIC_ uint32_t ndr_print_steal_switch_value(struct ndr_print *ndr, const void
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* retrieve a switch value and remove it from the list */
|
/* retrieve a switch value and remove it from the list */
|
||||||
_PUBLIC_ uint32_t ndr_pull_steal_switch_value(struct ndr_pull *ndr, const void *p)
|
_PUBLIC_ enum ndr_err_code ndr_pull_steal_switch_value(struct ndr_pull *ndr,
|
||||||
|
const void *p,
|
||||||
|
uint32_t *v)
|
||||||
{
|
{
|
||||||
enum ndr_err_code status;
|
return ndr_token_retrieve(&ndr->switch_list, p, v);
|
||||||
uint32_t v;
|
|
||||||
|
|
||||||
status = ndr_token_retrieve(&ndr->switch_list, p, &v);
|
|
||||||
if (!NDR_ERR_CODE_IS_SUCCESS(status)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return v;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -420,7 +420,8 @@ enum ndr_err_code ndr_push_drsuapi_DsBindInfo(struct ndr_push *ndr, int ndr_flag
|
|||||||
ndr->flags = ndr->flags & ~LIBNDR_FLAG_NDR64;
|
ndr->flags = ndr->flags & ~LIBNDR_FLAG_NDR64;
|
||||||
NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
|
NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
|
||||||
if (ndr_flags & NDR_SCALARS) {
|
if (ndr_flags & NDR_SCALARS) {
|
||||||
uint32_t level = ndr_push_steal_switch_value(ndr, r);
|
uint32_t level;
|
||||||
|
NDR_CHECK(ndr_push_steal_switch_value(ndr, r, &level));
|
||||||
NDR_CHECK(ndr_push_union_align(ndr, 4));
|
NDR_CHECK(ndr_push_union_align(ndr, 4));
|
||||||
switch (level) {
|
switch (level) {
|
||||||
case 24: {
|
case 24: {
|
||||||
@ -480,7 +481,8 @@ enum ndr_err_code ndr_pull_drsuapi_DsBindInfo(struct ndr_pull *ndr, int ndr_flag
|
|||||||
ndr->flags = ndr->flags & ~LIBNDR_FLAG_NDR64;
|
ndr->flags = ndr->flags & ~LIBNDR_FLAG_NDR64;
|
||||||
NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
|
NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
|
||||||
if (ndr_flags & NDR_SCALARS) {
|
if (ndr_flags & NDR_SCALARS) {
|
||||||
uint32_t level = ndr_pull_steal_switch_value(ndr, r);
|
uint32_t level;
|
||||||
|
NDR_CHECK(ndr_pull_steal_switch_value(ndr, r, &level));
|
||||||
NDR_CHECK(ndr_pull_union_align(ndr, 4));
|
NDR_CHECK(ndr_pull_union_align(ndr, 4));
|
||||||
switch (level) {
|
switch (level) {
|
||||||
case 24: {
|
case 24: {
|
||||||
|
@ -1983,7 +1983,7 @@ sub ParseUnionPush($$$$)
|
|||||||
$self->pidl("if (ndr_flags & NDR_SCALARS) {");
|
$self->pidl("if (ndr_flags & NDR_SCALARS) {");
|
||||||
$self->indent;
|
$self->indent;
|
||||||
$self->pidl("/* This token is not used again (except perhaps below in the NDR_BUFFERS case) */");
|
$self->pidl("/* This token is not used again (except perhaps below in the NDR_BUFFERS case) */");
|
||||||
$self->pidl("level = ndr_push_steal_switch_value($ndr, $varname);");
|
$self->pidl("NDR_CHECK(ndr_push_steal_switch_value($ndr, $varname, &level));");
|
||||||
|
|
||||||
$self->ParseUnionPushPrimitives($e, $ndr, $varname);
|
$self->ParseUnionPushPrimitives($e, $ndr, $varname);
|
||||||
$self->deindent;
|
$self->deindent;
|
||||||
@ -1995,7 +1995,7 @@ sub ParseUnionPush($$$$)
|
|||||||
$self->pidl("if (!(ndr_flags & NDR_SCALARS)) {");
|
$self->pidl("if (!(ndr_flags & NDR_SCALARS)) {");
|
||||||
$self->indent;
|
$self->indent;
|
||||||
$self->pidl("/* We didn't get it above, and the token is not needed after this. */");
|
$self->pidl("/* We didn't get it above, and the token is not needed after this. */");
|
||||||
$self->pidl("level = ndr_push_steal_switch_value($ndr, $varname);");
|
$self->pidl("NDR_CHECK(ndr_push_steal_switch_value($ndr, $varname, &level));");
|
||||||
$self->deindent;
|
$self->deindent;
|
||||||
$self->pidl("}");
|
$self->pidl("}");
|
||||||
$self->ParseUnionPushDeferred($e, $ndr, $varname);
|
$self->ParseUnionPushDeferred($e, $ndr, $varname);
|
||||||
@ -2171,7 +2171,7 @@ sub ParseUnionPull($$$$)
|
|||||||
$self->pidl("if (ndr_flags & NDR_SCALARS) {");
|
$self->pidl("if (ndr_flags & NDR_SCALARS) {");
|
||||||
$self->indent;
|
$self->indent;
|
||||||
$self->pidl("/* This token is not used again (except perhaps below in the NDR_BUFFERS case) */");
|
$self->pidl("/* This token is not used again (except perhaps below in the NDR_BUFFERS case) */");
|
||||||
$self->pidl("level = ndr_pull_steal_switch_value($ndr, $varname);");
|
$self->pidl("NDR_CHECK(ndr_pull_steal_switch_value($ndr, $varname, &level));");
|
||||||
$self->ParseUnionPullPrimitives($e,$ndr,$varname,$switch_type);
|
$self->ParseUnionPullPrimitives($e,$ndr,$varname,$switch_type);
|
||||||
$self->deindent;
|
$self->deindent;
|
||||||
$self->pidl("}");
|
$self->pidl("}");
|
||||||
@ -2182,7 +2182,7 @@ sub ParseUnionPull($$$$)
|
|||||||
$self->pidl("if (!(ndr_flags & NDR_SCALARS)) {");
|
$self->pidl("if (!(ndr_flags & NDR_SCALARS)) {");
|
||||||
$self->indent;
|
$self->indent;
|
||||||
$self->pidl("/* We didn't get it above, and the token is not needed after this. */");
|
$self->pidl("/* We didn't get it above, and the token is not needed after this. */");
|
||||||
$self->pidl("level = ndr_pull_steal_switch_value($ndr, $varname);");
|
$self->pidl("NDR_CHECK(ndr_pull_steal_switch_value($ndr, $varname, &level));");
|
||||||
$self->deindent;
|
$self->deindent;
|
||||||
$self->pidl("}");
|
$self->pidl("}");
|
||||||
$self->ParseUnionPullDeferred($e,$ndr,$varname);
|
$self->ParseUnionPullDeferred($e,$ndr,$varname);
|
||||||
|
Loading…
Reference in New Issue
Block a user