From fd2bc081381eb24bdbb82d0b1b0fbf0ae12f250a Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 23 Mar 2010 18:45:20 -0400 Subject: [PATCH] idl: fix forest trust information idl --validate now passes --- librpc/gen_ndr/drsblobs.h | 14 ++++--- librpc/gen_ndr/ndr_drsblobs.c | 85 +++++++++++++++++++++++++++++++++++-------- librpc/gen_ndr/ndr_drsblobs.h | 4 ++ librpc/idl/drsblobs.idl | 10 +++-- librpc/idl/idl_types.h | 5 ++- 5 files changed, 92 insertions(+), 26 deletions(-) diff --git a/librpc/gen_ndr/drsblobs.h b/librpc/gen_ndr/drsblobs.h index 83a6978353b..18ca55879b9 100644 --- a/librpc/gen_ndr/drsblobs.h +++ b/librpc/gen_ndr/drsblobs.h @@ -460,8 +460,8 @@ struct ExtendedErrorInfoPtr { struct ForestTrustDataDomainInfo { uint32_t sid_size;/* [value(ndr_size_dom_sid0(&sid,ndr->flags))] */ struct dom_sid sid;/* [subcontext_size(sid_size),subcontext(0)] */ - const char * dns_name;/* [flag(LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_SIZE4)] */ - const char * netbios_name;/* [flag(LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_SIZE4)] */ + const char * dns_name;/* [flag(LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_NOTERM)] */ + const char * netbios_name;/* [flag(LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_NOTERM)] */ }/* [flag(LIBNDR_FLAG_NOALIGN)] */; struct ForestTrustDataBinaryData { @@ -470,7 +470,7 @@ struct ForestTrustDataBinaryData { }/* [flag(LIBNDR_FLAG_NOALIGN)] */; union ForestTrustData { - const char * name;/* [flag(LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_SIZE4),case(FOREST_TRUST_TOP_LEVEL_NAME)] */ + const char * name;/* [flag(LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_NOTERM),case(FOREST_TRUST_TOP_LEVEL_NAME)] */ struct ForestTrustDataDomainInfo info;/* [case(FOREST_TRUST_DOMAIN_INFO)] */ struct ForestTrustDataBinaryData data;/* [default] */ }/* [nodiscriminant] */; @@ -491,17 +491,21 @@ enum ForestTrustInfoRecordType ; struct ForestTrustInfoRecord { - uint32_t length; uint32_t flags; NTTIME timestamp; enum ForestTrustInfoRecordType type; union ForestTrustData data;/* [switch_is(type)] */ +}/* [gensize,public,flag(LIBNDR_FLAG_NOALIGN)] */; + +struct ForestTrustInfoRecordArmor { + uint32_t record_size;/* [value(ndr_size_ForestTrustInfoRecord(&record,ndr->iconv_convenience,ndr->flags))] */ + struct ForestTrustInfoRecord record; }/* [flag(LIBNDR_FLAG_NOALIGN)] */; struct ForestTrustInfo { uint32_t version; uint32_t count; - struct ForestTrustInfoRecord *records; + struct ForestTrustInfoRecordArmor *records; }/* [public,flag(LIBNDR_FLAG_NOALIGN)] */; diff --git a/librpc/gen_ndr/ndr_drsblobs.c b/librpc/gen_ndr/ndr_drsblobs.c index aa2eeb7da26..1ff7aefc87f 100644 --- a/librpc/gen_ndr/ndr_drsblobs.c +++ b/librpc/gen_ndr/ndr_drsblobs.c @@ -4074,13 +4074,13 @@ static enum ndr_err_code ndr_push_ForestTrustDataDomainInfo(struct ndr_push *ndr } { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_SIZE4); + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_NOTERM); NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->dns_name)); ndr->flags = _flags_save_string; } { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_SIZE4); + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_NOTERM); NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->netbios_name)); ndr->flags = _flags_save_string; } @@ -4109,13 +4109,13 @@ static enum ndr_err_code ndr_pull_ForestTrustDataDomainInfo(struct ndr_pull *ndr } { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_SIZE4); + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_NOTERM); NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->dns_name)); ndr->flags = _flags_save_string; } { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_SIZE4); + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_NOTERM); NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->netbios_name)); ndr->flags = _flags_save_string; } @@ -4204,7 +4204,7 @@ static enum ndr_err_code ndr_push_ForestTrustData(struct ndr_push *ndr, int ndr_ case FOREST_TRUST_TOP_LEVEL_NAME: { { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_SIZE4); + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_NOTERM); NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->name)); ndr->flags = _flags_save_string; } @@ -4213,7 +4213,7 @@ static enum ndr_err_code ndr_push_ForestTrustData(struct ndr_push *ndr, int ndr_ case FOREST_TRUST_TOP_LEVEL_NAME_EX: { { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_SIZE4); + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_NOTERM); NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->name)); ndr->flags = _flags_save_string; } @@ -4259,7 +4259,7 @@ static enum ndr_err_code ndr_pull_ForestTrustData(struct ndr_pull *ndr, int ndr_ case FOREST_TRUST_TOP_LEVEL_NAME: { { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_SIZE4); + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_NOTERM); NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->name)); ndr->flags = _flags_save_string; } @@ -4268,7 +4268,7 @@ static enum ndr_err_code ndr_pull_ForestTrustData(struct ndr_pull *ndr, int ndr_ case FOREST_TRUST_TOP_LEVEL_NAME_EX: { { uint32_t _flags_save_string = ndr->flags; - ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_SIZE4); + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_NOTERM); NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->name)); ndr->flags = _flags_save_string; } @@ -4354,14 +4354,13 @@ _PUBLIC_ void ndr_print_ForestTrustInfoRecordType(struct ndr_print *ndr, const c ndr_print_enum(ndr, name, "ENUM", val, r); } -static enum ndr_err_code ndr_push_ForestTrustInfoRecord(struct ndr_push *ndr, int ndr_flags, const struct ForestTrustInfoRecord *r) +_PUBLIC_ enum ndr_err_code ndr_push_ForestTrustInfoRecord(struct ndr_push *ndr, int ndr_flags, const struct ForestTrustInfoRecord *r) { { uint32_t _flags_save_STRUCT = ndr->flags; ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_push_align(ndr, 4)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->length)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->flags)); NDR_CHECK(ndr_push_NTTIME(ndr, NDR_SCALARS, r->timestamp)); NDR_CHECK(ndr_push_ForestTrustInfoRecordType(ndr, NDR_SCALARS, r->type)); @@ -4376,14 +4375,13 @@ static enum ndr_err_code ndr_push_ForestTrustInfoRecord(struct ndr_push *ndr, in return NDR_ERR_SUCCESS; } -static enum ndr_err_code ndr_pull_ForestTrustInfoRecord(struct ndr_pull *ndr, int ndr_flags, struct ForestTrustInfoRecord *r) +_PUBLIC_ enum ndr_err_code ndr_pull_ForestTrustInfoRecord(struct ndr_pull *ndr, int ndr_flags, struct ForestTrustInfoRecord *r) { { uint32_t _flags_save_STRUCT = ndr->flags; ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); if (ndr_flags & NDR_SCALARS) { NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->length)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->flags)); NDR_CHECK(ndr_pull_NTTIME(ndr, NDR_SCALARS, &r->timestamp)); NDR_CHECK(ndr_pull_ForestTrustInfoRecordType(ndr, NDR_SCALARS, &r->type)); @@ -4405,7 +4403,6 @@ _PUBLIC_ void ndr_print_ForestTrustInfoRecord(struct ndr_print *ndr, const char uint32_t _flags_save_STRUCT = ndr->flags; ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); ndr->depth++; - ndr_print_uint32(ndr, "length", r->length); ndr_print_uint32(ndr, "flags", r->flags); ndr_print_NTTIME(ndr, "timestamp", r->timestamp); ndr_print_ForestTrustInfoRecordType(ndr, "type", r->type); @@ -4416,6 +4413,62 @@ _PUBLIC_ void ndr_print_ForestTrustInfoRecord(struct ndr_print *ndr, const char } } +_PUBLIC_ size_t ndr_size_ForestTrustInfoRecord(const struct ForestTrustInfoRecord *r, struct smb_iconv_convenience *ic, int flags) +{ + flags |= LIBNDR_FLAG_NOALIGN; + return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_ForestTrustInfoRecord, ic); +} + +static enum ndr_err_code ndr_push_ForestTrustInfoRecordArmor(struct ndr_push *ndr, int ndr_flags, const struct ForestTrustInfoRecordArmor *r) +{ + { + uint32_t _flags_save_STRUCT = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_size_ForestTrustInfoRecord(&r->record, ndr->iconv_convenience, ndr->flags))); + NDR_CHECK(ndr_push_ForestTrustInfoRecord(ndr, NDR_SCALARS, &r->record)); + NDR_CHECK(ndr_push_trailer_align(ndr, 4)); + } + if (ndr_flags & NDR_BUFFERS) { + } + ndr->flags = _flags_save_STRUCT; + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code ndr_pull_ForestTrustInfoRecordArmor(struct ndr_pull *ndr, int ndr_flags, struct ForestTrustInfoRecordArmor *r) +{ + { + uint32_t _flags_save_STRUCT = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->record_size)); + NDR_CHECK(ndr_pull_ForestTrustInfoRecord(ndr, NDR_SCALARS, &r->record)); + NDR_CHECK(ndr_pull_trailer_align(ndr, 4)); + } + if (ndr_flags & NDR_BUFFERS) { + } + ndr->flags = _flags_save_STRUCT; + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ void ndr_print_ForestTrustInfoRecordArmor(struct ndr_print *ndr, const char *name, const struct ForestTrustInfoRecordArmor *r) +{ + ndr_print_struct(ndr, name, "ForestTrustInfoRecordArmor"); + { + uint32_t _flags_save_STRUCT = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); + ndr->depth++; + ndr_print_uint32(ndr, "record_size", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?ndr_size_ForestTrustInfoRecord(&r->record, ndr->iconv_convenience, ndr->flags):r->record_size); + ndr_print_ForestTrustInfoRecord(ndr, "record", &r->record); + ndr->depth--; + ndr->flags = _flags_save_STRUCT; + } +} + _PUBLIC_ enum ndr_err_code ndr_push_ForestTrustInfo(struct ndr_push *ndr, int ndr_flags, const struct ForestTrustInfo *r) { uint32_t cntr_records_0; @@ -4427,7 +4480,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_ForestTrustInfo(struct ndr_push *ndr, int nd NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->version)); NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->count)); for (cntr_records_0 = 0; cntr_records_0 < r->count; cntr_records_0++) { - NDR_CHECK(ndr_push_ForestTrustInfoRecord(ndr, NDR_SCALARS, &r->records[cntr_records_0])); + NDR_CHECK(ndr_push_ForestTrustInfoRecordArmor(ndr, NDR_SCALARS, &r->records[cntr_records_0])); } NDR_CHECK(ndr_push_trailer_align(ndr, 4)); } @@ -4453,7 +4506,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_ForestTrustInfo(struct ndr_pull *ndr, int nd _mem_save_records_0 = NDR_PULL_GET_MEM_CTX(ndr); NDR_PULL_SET_MEM_CTX(ndr, r->records, 0); for (cntr_records_0 = 0; cntr_records_0 < r->count; cntr_records_0++) { - NDR_CHECK(ndr_pull_ForestTrustInfoRecord(ndr, NDR_SCALARS, &r->records[cntr_records_0])); + NDR_CHECK(ndr_pull_ForestTrustInfoRecordArmor(ndr, NDR_SCALARS, &r->records[cntr_records_0])); } NDR_PULL_SET_MEM_CTX(ndr, _mem_save_records_0, 0); NDR_CHECK(ndr_pull_trailer_align(ndr, 4)); @@ -4480,7 +4533,7 @@ _PUBLIC_ void ndr_print_ForestTrustInfo(struct ndr_print *ndr, const char *name, for (cntr_records_0=0;cntr_records_0count;cntr_records_0++) { char *idx_0=NULL; if (asprintf(&idx_0, "[%d]", cntr_records_0) != -1) { - ndr_print_ForestTrustInfoRecord(ndr, "records", &r->records[cntr_records_0]); + ndr_print_ForestTrustInfoRecordArmor(ndr, "records", &r->records[cntr_records_0]); free(idx_0); } } diff --git a/librpc/gen_ndr/ndr_drsblobs.h b/librpc/gen_ndr/ndr_drsblobs.h index 226403d7eba..7831fad3618 100644 --- a/librpc/gen_ndr/ndr_drsblobs.h +++ b/librpc/gen_ndr/ndr_drsblobs.h @@ -162,7 +162,11 @@ void ndr_print_ForestTrustDataDomainInfo(struct ndr_print *ndr, const char *name void ndr_print_ForestTrustDataBinaryData(struct ndr_print *ndr, const char *name, const struct ForestTrustDataBinaryData *r); void ndr_print_ForestTrustData(struct ndr_print *ndr, const char *name, const union ForestTrustData *r); void ndr_print_ForestTrustInfoRecordType(struct ndr_print *ndr, const char *name, enum ForestTrustInfoRecordType r); +enum ndr_err_code ndr_push_ForestTrustInfoRecord(struct ndr_push *ndr, int ndr_flags, const struct ForestTrustInfoRecord *r); +enum ndr_err_code ndr_pull_ForestTrustInfoRecord(struct ndr_pull *ndr, int ndr_flags, struct ForestTrustInfoRecord *r); void ndr_print_ForestTrustInfoRecord(struct ndr_print *ndr, const char *name, const struct ForestTrustInfoRecord *r); +size_t ndr_size_ForestTrustInfoRecord(const struct ForestTrustInfoRecord *r, struct smb_iconv_convenience *ic, int flags); +void ndr_print_ForestTrustInfoRecordArmor(struct ndr_print *ndr, const char *name, const struct ForestTrustInfoRecordArmor *r); enum ndr_err_code ndr_push_ForestTrustInfo(struct ndr_push *ndr, int ndr_flags, const struct ForestTrustInfo *r); enum ndr_err_code ndr_pull_ForestTrustInfo(struct ndr_pull *ndr, int ndr_flags, struct ForestTrustInfo *r); void ndr_print_ForestTrustInfo(struct ndr_print *ndr, const char *name, const struct ForestTrustInfo *r); diff --git a/librpc/idl/drsblobs.idl b/librpc/idl/drsblobs.idl index 7cfcc1c3c56..0df5bc15e2e 100644 --- a/librpc/idl/drsblobs.idl +++ b/librpc/idl/drsblobs.idl @@ -602,18 +602,22 @@ interface drsblobs { /* meaning of flags depends on record type and values are the same as in lsa.idl, see collision record types */ - typedef [flag(NDR_NOALIGN)] struct { - uint32 length; + typedef [public,gensize,flag(NDR_NOALIGN)] struct { uint32 flags; NTTIME timestamp; ForestTrustInfoRecordType type; [switch_is(type)] ForestTrustData data; } ForestTrustInfoRecord; + typedef [flag(NDR_NOALIGN)] struct { + [value(ndr_size_ForestTrustInfoRecord(&record, ndr->iconv_convenience, ndr->flags))] uint32 record_size; + ForestTrustInfoRecord record; + } ForestTrustInfoRecordArmor; + typedef [public,flag(NDR_NOALIGN)] struct { uint32 version; uint32 count; - ForestTrustInfoRecord records[count]; + ForestTrustInfoRecordArmor records[count]; } ForestTrustInfo; void decode_ForestTrustInfo( diff --git a/librpc/idl/idl_types.h b/librpc/idl/idl_types.h index e8b3da578ff..d763a8b22a3 100644 --- a/librpc/idl/idl_types.h +++ b/librpc/idl/idl_types.h @@ -48,9 +48,10 @@ #define utf8string [flag(STR_UTF8|STR_NULLTERM)] string /* - an utf8 string prefixed with [size], 32 bits + an utf8 string prefixed with [length], 32 bits + not null terminated */ -#define utf8string2 [flag(STR_UTF8|STR_SIZE4)] string +#define utf8string2 [flag(STR_SIZE4|STR_UTF8|STR_NOTERM)] string /* a null terminated UCS2 string -- 2.11.4.GIT