From 64e08fef16001d62b43f6925a26ad739391cface Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 29 Sep 2009 17:47:54 +1000 Subject: pidl: added union padding for NDR64 This fixes the problem with samr UserInfo16 when NDR64 is enabled --- librpc/ndr/ndr_basic.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'librpc/ndr/ndr_basic.c') diff --git a/librpc/ndr/ndr_basic.c b/librpc/ndr/ndr_basic.c index 00e33ad9d0..f3b7e755c5 100644 --- a/librpc/ndr/ndr_basic.c +++ b/librpc/ndr/ndr_basic.c @@ -555,6 +555,24 @@ _PUBLIC_ enum ndr_err_code ndr_pull_align(struct ndr_pull *ndr, size_t size) return NDR_ERR_SUCCESS; } +_PUBLIC_ enum ndr_err_code ndr_push_union_align(struct ndr_push *ndr, size_t size) +{ + /* MS-RPCE section 2.2.5.3.4.4 */ + if (ndr->flags & LIBNDR_FLAG_NDR64) { + return ndr_push_align(ndr, size); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_union_align(struct ndr_pull *ndr, size_t size) +{ + /* MS-RPCE section 2.2.5.3.4.4 */ + if (ndr->flags & LIBNDR_FLAG_NDR64) { + return ndr_pull_align(ndr, size); + } + return NDR_ERR_SUCCESS; +} + /* push some bytes */ -- cgit From 9eb78be4a670615b4e6a722f121f0f0e585b8d6b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 1 Oct 2009 16:08:02 +1000 Subject: ndr64: added support for trailing gap alignment NDR64 has a 'trailing gap' alignment, which aligns the end of a structure on the overall structure alignment. This explains the discrepancy we had with the RPC-SAMR test and NDR64 --- librpc/ndr/ndr_basic.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'librpc/ndr/ndr_basic.c') diff --git a/librpc/ndr/ndr_basic.c b/librpc/ndr/ndr_basic.c index f3b7e755c5..807db59995 100644 --- a/librpc/ndr/ndr_basic.c +++ b/librpc/ndr/ndr_basic.c @@ -573,6 +573,24 @@ _PUBLIC_ enum ndr_err_code ndr_pull_union_align(struct ndr_pull *ndr, size_t siz return NDR_ERR_SUCCESS; } +_PUBLIC_ enum ndr_err_code ndr_push_trailer_align(struct ndr_push *ndr, size_t size) +{ + /* MS-RPCE section 2.2.5.3.4.1 */ + if (ndr->flags & LIBNDR_FLAG_NDR64) { + return ndr_push_align(ndr, size); + } + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_pull_trailer_align(struct ndr_pull *ndr, size_t size) +{ + /* MS-RPCE section 2.2.5.3.4.1 */ + if (ndr->flags & LIBNDR_FLAG_NDR64) { + return ndr_pull_align(ndr, size); + } + return NDR_ERR_SUCCESS; +} + /* push some bytes */ -- cgit From f21fb4b3958fe630400b145b729c966fa9c053a9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 3 Oct 2009 18:13:25 +1000 Subject: pidl: added int3264 as a base type This is the type used for a variable that is 32 bits for NDR32 and 64 bits for NDR64 --- librpc/ndr/ndr_basic.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'librpc/ndr/ndr_basic.c') diff --git a/librpc/ndr/ndr_basic.c b/librpc/ndr/ndr_basic.c index 807db59995..1a19cc9327 100644 --- a/librpc/ndr/ndr_basic.c +++ b/librpc/ndr/ndr_basic.c @@ -842,6 +842,16 @@ _PUBLIC_ void ndr_print_uint32(struct ndr_print *ndr, const char *name, uint32_t ndr->print(ndr, "%-25s: 0x%08x (%u)", name, v, v); } +_PUBLIC_ void ndr_print_int3264(struct ndr_print *ndr, const char *name, int32_t v) +{ + ndr->print(ndr, "%-25s: %d", name, v); +} + +_PUBLIC_ void ndr_print_uint3264(struct ndr_print *ndr, const char *name, uint32_t v) +{ + ndr->print(ndr, "%-25s: 0x%08x (%u)", name, v, v); +} + _PUBLIC_ void ndr_print_udlong(struct ndr_print *ndr, const char *name, uint64_t v) { ndr->print(ndr, "%-25s: 0x%016llx (%llu)", name, (unsigned long long)v, (unsigned long long)v); -- cgit From 2bf8a7485cf0733c808bc97a399a1c73bb988414 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 6 Oct 2009 20:47:09 +1100 Subject: pidl: get the alignment right for uint1632 enums (NDR64) The default enum in NDR63 is 32 bits, not 16 bits. We need a uint1632 type to get the alignment right. --- librpc/ndr/ndr_basic.c | 78 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 63 insertions(+), 15 deletions(-) (limited to 'librpc/ndr/ndr_basic.c') diff --git a/librpc/ndr/ndr_basic.c b/librpc/ndr/ndr_basic.c index 1a19cc9327..64fa5a6299 100644 --- a/librpc/ndr/ndr_basic.c +++ b/librpc/ndr/ndr_basic.c @@ -101,6 +101,24 @@ _PUBLIC_ enum ndr_err_code ndr_pull_uint16(struct ndr_pull *ndr, int ndr_flags, return NDR_ERR_SUCCESS; } +/* + parse a uint1632_t +*/ +_PUBLIC_ enum ndr_err_code ndr_pull_uint1632(struct ndr_pull *ndr, int ndr_flags, uint16_t *v) +{ + if (unlikely(ndr->flags & LIBNDR_FLAG_NDR64)) { + uint32_t v32 = 0; + enum ndr_err_code err = ndr_pull_uint32(ndr, ndr_flags, &v32); + *v = v32; + if (unlikely(v32 != *v)) { + DEBUG(0,(__location__ ": non-zero upper 16 bits 0x%08x\n", (unsigned)v32)); + return NDR_ERR_NDR64; + } + return err; + } + return ndr_pull_uint16(ndr, ndr_flags, v); +} + /* parse a int32_t */ @@ -282,9 +300,17 @@ _PUBLIC_ enum ndr_err_code ndr_pull_enum_uint8(struct ndr_pull *ndr, int ndr_fla } /* - parse a uint16_t enum (uint32_t on NDR64) + parse a uint16_t enum */ _PUBLIC_ enum ndr_err_code ndr_pull_enum_uint16(struct ndr_pull *ndr, int ndr_flags, uint16_t *v) +{ + return ndr_pull_uint16(ndr, ndr_flags, v); +} + +/* + parse a uint1632_t enum (uint32_t on NDR64) +*/ +_PUBLIC_ enum ndr_err_code ndr_pull_enum_uint1632(struct ndr_pull *ndr, int ndr_flags, uint16_t *v) { if (unlikely(ndr->flags & LIBNDR_FLAG_NDR64)) { uint32_t v32; @@ -296,11 +322,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_enum_uint16(struct ndr_pull *ndr, int ndr_fl } return NDR_ERR_SUCCESS; } - NDR_PULL_ALIGN(ndr, 2); - NDR_PULL_NEED_BYTES(ndr, 2); - *v = NDR_SVAL(ndr, ndr->offset); - ndr->offset += 2; - return NDR_ERR_SUCCESS; + return ndr_pull_uint16(ndr, ndr_flags, v); } /* @@ -320,13 +342,10 @@ _PUBLIC_ enum ndr_err_code ndr_push_enum_uint8(struct ndr_push *ndr, int ndr_fla } /* - push a uint16_t enum (uint32_t on NDR64) + push a uint16_t enum */ _PUBLIC_ enum ndr_err_code ndr_push_enum_uint16(struct ndr_push *ndr, int ndr_flags, uint16_t v) { - if (unlikely(ndr->flags & LIBNDR_FLAG_NDR64)) { - return ndr_push_uint32(ndr, ndr_flags, v); - } return ndr_push_uint16(ndr, ndr_flags, v); } @@ -338,6 +357,16 @@ _PUBLIC_ enum ndr_err_code ndr_push_enum_uint32(struct ndr_push *ndr, int ndr_fl return ndr_push_uint32(ndr, ndr_flags, v); } +/* + push a uint1632_t enum +*/ +_PUBLIC_ enum ndr_err_code ndr_push_enum_uint1632(struct ndr_push *ndr, int ndr_flags, uint16_t v) +{ + if (unlikely(ndr->flags & LIBNDR_FLAG_NDR64)) { + return ndr_push_uint32(ndr, ndr_flags, v); + } + return ndr_push_uint16(ndr, ndr_flags, v); +} /* push a WERROR @@ -420,6 +449,17 @@ _PUBLIC_ enum ndr_err_code ndr_push_uint16(struct ndr_push *ndr, int ndr_flags, return NDR_ERR_SUCCESS; } +/* + push a uint1632 +*/ +_PUBLIC_ enum ndr_err_code ndr_push_uint1632(struct ndr_push *ndr, int ndr_flags, uint16_t v) +{ + if (unlikely(ndr->flags & LIBNDR_FLAG_NDR64)) { + return ndr_push_uint32(ndr, ndr_flags, v); + } + return ndr_push_uint16(ndr, ndr_flags, v); +} + /* push a int32_t */ @@ -452,11 +492,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_uint3264(struct ndr_push *ndr, int ndr_flags if (unlikely(ndr->flags & LIBNDR_FLAG_NDR64)) { return ndr_push_hyper(ndr, ndr_flags, v); } - NDR_PUSH_ALIGN(ndr, 4); - NDR_PUSH_NEED_BYTES(ndr, 4); - NDR_SIVAL(ndr, ndr->offset, v); - ndr->offset += 4; - return NDR_ERR_SUCCESS; + return ndr_push_uint32(ndr, ndr_flags, v); } /* @@ -536,6 +572,12 @@ _PUBLIC_ enum ndr_err_code ndr_push_align(struct ndr_push *ndr, size_t size) } else { size = 4; } + } else if (size == 3) { + if (ndr->flags & LIBNDR_FLAG_NDR64) { + size = 4; + } else { + size = 2; + } } NDR_PUSH_ALIGN(ndr, size); return NDR_ERR_SUCCESS; @@ -550,6 +592,12 @@ _PUBLIC_ enum ndr_err_code ndr_pull_align(struct ndr_pull *ndr, size_t size) } else { size = 4; } + } else if (size == 3) { + if (ndr->flags & LIBNDR_FLAG_NDR64) { + size = 4; + } else { + size = 2; + } } NDR_PULL_ALIGN(ndr, size); return NDR_ERR_SUCCESS; -- cgit