From 4fa0f615f286631820316f8c87dd61eda494e203 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 6 Nov 2003 12:34:04 +0000 Subject: another major bit of restructuring of rpc in Samba4. Mostly moving files around, but also added the first bits of auto-generated code for the lsa pipe. I haven't updated the Makefile to call pidl yet, so for now the code was cut-and-pasted into librpc/ndr/ndr_lsa.c manually (This used to be commit 6b222d3b6541ee74cf8bf3f0913cd444903ca991) --- source4/librpc/ndr/ndr_basic.c | 279 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 279 insertions(+) create mode 100644 source4/librpc/ndr/ndr_basic.c (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c new file mode 100644 index 0000000000..3bd75e7c0d --- /dev/null +++ b/source4/librpc/ndr/ndr_basic.c @@ -0,0 +1,279 @@ +/* + Unix SMB/CIFS implementation. + + routines for marshalling/unmarshalling basic types + + Copyright (C) Andrew Tridgell 2003 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +#define NDR_PULL_NEED_BYTES(ndr, n) do { \ + if ((n) > ndr->data_size || ndr->offset + (n) > ndr->data_size) { \ + return NT_STATUS_BUFFER_TOO_SMALL; \ + } \ +} while(0) + +#define NDR_PULL_ALIGN(ndr, n) do { \ + ndr->offset = (ndr->offset + (n-1)) & ~(n-1); \ + if (ndr->offset >= ndr->data_size) { \ + return NT_STATUS_BUFFER_TOO_SMALL; \ + } \ +} while(0) + +/* + parse a uint8 +*/ +NTSTATUS ndr_pull_uint8(struct ndr_pull *ndr, uint8 *v) +{ + NDR_PULL_NEED_BYTES(ndr, 1); + *v = CVAL(ndr->data, ndr->offset); + ndr->offset += 1; + return NT_STATUS_OK; +} + + +/* + parse a uint16 +*/ +NTSTATUS ndr_pull_uint16(struct ndr_pull *ndr, uint16 *v) +{ + NDR_PULL_ALIGN(ndr, 2); + NDR_PULL_NEED_BYTES(ndr, 2); + if (ndr->flags & LIBNDR_FLAG_BIGENDIAN) { + *v = RSVAL(ndr->data, ndr->offset); + } else { + *v = SVAL(ndr->data, ndr->offset); + } + ndr->offset += 2; + return NT_STATUS_OK; +} + + +/* + parse a uint32 +*/ +NTSTATUS ndr_pull_uint32(struct ndr_pull *ndr, uint32 *v) +{ + NDR_PULL_ALIGN(ndr, 4); + NDR_PULL_NEED_BYTES(ndr, 4); + if (ndr->flags & LIBNDR_FLAG_BIGENDIAN) { + *v = RIVAL(ndr->data, ndr->offset); + } else { + *v = IVAL(ndr->data, ndr->offset); + } + ndr->offset += 4; + return NT_STATUS_OK; +} + +/* + pull a NTSTATUS +*/ +NTSTATUS ndr_pull_status(struct ndr_pull *ndr, NTSTATUS *status) +{ + uint32 v; + NDR_CHECK(ndr_pull_uint32(ndr, &v)); + *status = NT_STATUS(v); + return NT_STATUS_OK; +} + +/* + parse a set of bytes +*/ +NTSTATUS ndr_pull_bytes(struct ndr_pull *ndr, char *data, uint32 n) +{ + NDR_PULL_NEED_BYTES(ndr, n); + memcpy(data, ndr->data + ndr->offset, n); + ndr->offset += n; + return NT_STATUS_OK; +} + +/* + parse a GUID +*/ +NTSTATUS ndr_pull_guid(struct ndr_pull *ndr, GUID *guid) +{ + int i; + NDR_PULL_NEED_BYTES(ndr, GUID_SIZE); + for (i=0;iinfo[i] = CVAL(ndr->data, ndr->offset + i); + } + ndr->offset += i; + return NT_STATUS_OK; +} + + +#define NDR_PUSH_NEED_BYTES(ndr, n) NDR_CHECK(ndr_push_expand(ndr, ndr->offset+(n))) + +#define NDR_PUSH_ALIGN(ndr, n) do { \ + uint32 _pad = (ndr->offset & (n-1)); \ + while (_pad--) NDR_CHECK(ndr_push_uint8(ndr, 0)); \ +} while(0) + +/* + push a uint8 +*/ +NTSTATUS ndr_push_uint8(struct ndr_push *ndr, uint8 v) +{ + NDR_PUSH_NEED_BYTES(ndr, 1); + SCVAL(ndr->data, ndr->offset, v); + ndr->offset += 1; + return NT_STATUS_OK; +} + +/* + push a uint16 +*/ +NTSTATUS ndr_push_uint16(struct ndr_push *ndr, uint16 v) +{ + NDR_PUSH_ALIGN(ndr, 2); + NDR_PUSH_NEED_BYTES(ndr, 2); + SSVAL(ndr->data, ndr->offset, v); + ndr->offset += 2; + return NT_STATUS_OK; +} + +/* + push a uint32 +*/ +NTSTATUS ndr_push_uint32(struct ndr_push *ndr, uint32 v) +{ + NDR_PUSH_ALIGN(ndr, 4); + NDR_PUSH_NEED_BYTES(ndr, 4); + SIVAL(ndr->data, ndr->offset, v); + ndr->offset += 4; + return NT_STATUS_OK; +} + +/* + align to a uint32 +*/ +NTSTATUS ndr_push_align_uint32(struct ndr_push *ndr) +{ + NDR_PUSH_ALIGN(ndr, 4); + return NT_STATUS_OK; +} + +/* + push some bytes +*/ +NTSTATUS ndr_push_bytes(struct ndr_push *ndr, const char *data, uint32 n) +{ + NDR_PUSH_NEED_BYTES(ndr, n); + memcpy(ndr->data + ndr->offset, data, n); + ndr->offset += n; + return NT_STATUS_OK; +} + +/* + save the current position + */ +void ndr_push_save(struct ndr_push *ndr, struct ndr_push_save *save) +{ + save->offset = ndr->offset; +} + +/* + restore the position + */ +void ndr_push_restore(struct ndr_push *ndr, struct ndr_push_save *save) +{ + ndr->offset = save->offset; +} + +/* + this is used when a packet has a 4 byte length field. We remember the start position + and come back to it later to fill in the size +*/ +NTSTATUS ndr_push_length4_start(struct ndr_push *ndr, struct ndr_push_save *save) +{ + NDR_PUSH_ALIGN(ndr, 4); + ndr_push_save(ndr, save); + return ndr_push_uint32(ndr, 0); +} + +NTSTATUS ndr_push_length4_end(struct ndr_push *ndr, struct ndr_push_save *save) +{ + struct ndr_push_save save2; + ndr_push_save(ndr, &save2); + ndr_push_restore(ndr, save); + NDR_CHECK(ndr_push_uint32(ndr, save2.offset - ndr->offset)); + ndr_push_restore(ndr, &save2); + return NT_STATUS_OK; +} + +/* + push a 1 if a pointer is non-NULL, otherwise 0 +*/ +NTSTATUS ndr_push_ptr(struct ndr_push *ndr, const void *p) +{ + return ndr_push_uint32(ndr, p?1:0); +} + +/* + push a comformant, variable ucs2 string onto the wire from a C string +*/ +NTSTATUS ndr_push_unistr(struct ndr_push *ndr, const char *s) +{ + char *ws; + ssize_t len; + len = push_ucs2_talloc(ndr->mem_ctx, (smb_ucs2_t **)&ws, s); + if (len == -1) { + return NT_STATUS_INVALID_PARAMETER; + } + NDR_CHECK(ndr_push_uint32(ndr, len/2)); + NDR_CHECK(ndr_push_uint32(ndr, 0)); + NDR_CHECK(ndr_push_uint32(ndr, len/2)); + NDR_CHECK(ndr_push_bytes(ndr, ws, len)); + return NT_STATUS_OK; +} + +/* + push a 4 byte offset pointer, remembering where we are so we can later fill + in the correct value +*/ +NTSTATUS ndr_push_offset(struct ndr_push *ndr, struct ndr_push_save *ofs) +{ + NDR_PUSH_ALIGN(ndr, 4); + ndr_push_save(ndr, ofs); + return ndr_push_uint32(ndr, 0); +} + +/* + fill in the correct offset in a saved offset pointer + the offset is taken relative to 'save' +*/ +NTSTATUS ndr_push_offset_ptr(struct ndr_push *ndr, + struct ndr_push_save *ofs, + struct ndr_push_save *save) +{ + struct ndr_push_save save2; + ndr_push_save(ndr, &save2); + ndr_push_restore(ndr, ofs); + NDR_CHECK(ndr_push_uint32(ndr, save2.offset - save->offset)); + ndr_push_restore(ndr, &save2); + return NT_STATUS_OK; +} + + +/* + push a GUID +*/ +NTSTATUS ndr_push_guid(struct ndr_push *ndr, GUID *guid) +{ + return ndr_push_bytes(ndr, guid->info, GUID_SIZE); +} -- cgit From 7d212460a5c00b4039440c2db0dde56e7d519d66 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 8 Nov 2003 11:21:57 +0000 Subject: - corrected some lsa idl - updated lsa parse code from pidl (This used to be commit 3983b2aee77b0e093847bfc02e02b83ab281f5dd) --- source4/librpc/ndr/ndr_basic.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 3bd75e7c0d..0597bcab00 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -242,6 +242,32 @@ NTSTATUS ndr_push_unistr(struct ndr_push *ndr, const char *s) return NT_STATUS_OK; } +/* + pull a comformant, variable ucs2 string from the wire into a C string +*/ +NTSTATUS ndr_pull_unistr(struct ndr_pull *ndr, const char **s) +{ + char *ws, *as=NULL; + uint32 len1, ofs, len2; + + NDR_CHECK(ndr_pull_uint32(ndr, &len1)); + NDR_CHECK(ndr_pull_uint32(ndr, &ofs)); + NDR_CHECK(ndr_pull_uint32(ndr, &len2)); + if (len2 > len1) { + return NT_STATUS_INVALID_PARAMETER; + } + NDR_ALLOC_N(ndr, ws, (len1+1)*2); + NDR_CHECK(ndr_pull_bytes(ndr, ws, len1*2)); + SSVAL(ws, len1*2, 0); + SSVAL(ws, len2*2, 0); + pull_ucs2_talloc(ndr->mem_ctx, &as, (const smb_ucs2_t *)ws); + if (!as) { + return NT_STATUS_INVALID_PARAMETER; + } + *s = as; + return NT_STATUS_OK; +} + /* push a 4 byte offset pointer, remembering where we are so we can later fill in the correct value -- cgit From 668c938678fd7f08ca1ad3412d090f487295211f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 8 Nov 2003 13:23:20 +0000 Subject: - more generation fixes - added auto-generation from the Makefile. Only called when you run "make idl" (This used to be commit 47a17e5a08dcb5ef2880f75a59bf417e161a71d3) --- source4/librpc/ndr/ndr_basic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 0597bcab00..21bd36963c 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -83,7 +83,7 @@ NTSTATUS ndr_pull_uint32(struct ndr_pull *ndr, uint32 *v) /* pull a NTSTATUS */ -NTSTATUS ndr_pull_status(struct ndr_pull *ndr, NTSTATUS *status) +NTSTATUS ndr_pull_NTSTATUS(struct ndr_pull *ndr, NTSTATUS *status) { uint32 v; NDR_CHECK(ndr_pull_uint32(ndr, &v)); -- cgit From cff32d6b0ae3b8f17973f544d8be891704437915 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 9 Nov 2003 00:58:40 +0000 Subject: added idl, generated code and test code for lsa_LookupSids (This used to be commit afa1ff5f08fceba3d34b4e0965fe7e0c0143ede9) --- source4/librpc/ndr/ndr_basic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 21bd36963c..3e6d0b30e6 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -257,7 +257,7 @@ NTSTATUS ndr_pull_unistr(struct ndr_pull *ndr, const char **s) return NT_STATUS_INVALID_PARAMETER; } NDR_ALLOC_N(ndr, ws, (len1+1)*2); - NDR_CHECK(ndr_pull_bytes(ndr, ws, len1*2)); + NDR_CHECK(ndr_pull_bytes(ndr, ws, len2*2)); SSVAL(ws, len1*2, 0); SSVAL(ws, len2*2, 0); pull_ucs2_talloc(ndr->mem_ctx, &as, (const smb_ucs2_t *)ws); -- cgit From 946d358646977e265cb36b34324a1145c6121870 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 9 Nov 2003 02:21:24 +0000 Subject: lsa_LookupNames now works (This used to be commit fba3a7ad22edcbe394861e42b5e5c53709e9d5fe) --- source4/librpc/ndr/ndr_basic.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 3e6d0b30e6..6ada49997f 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -221,7 +221,7 @@ NTSTATUS ndr_push_length4_end(struct ndr_push *ndr, struct ndr_push_save *save) */ NTSTATUS ndr_push_ptr(struct ndr_push *ndr, const void *p) { - return ndr_push_uint32(ndr, p?1:0); + return ndr_push_uint32(ndr, p?0xaabbccdd:0); } /* @@ -242,6 +242,25 @@ NTSTATUS ndr_push_unistr(struct ndr_push *ndr, const char *s) return NT_STATUS_OK; } +/* + push a comformant, variable ucs2 string onto the wire from a C string + don't send the null +*/ +NTSTATUS ndr_push_unistr_noterm(struct ndr_push *ndr, const char *s) +{ + char *ws; + ssize_t len; + len = push_ucs2_talloc(ndr->mem_ctx, (smb_ucs2_t **)&ws, s); + if (len == -1) { + return NT_STATUS_INVALID_PARAMETER; + } + NDR_CHECK(ndr_push_uint32(ndr, len/2 - 1)); + NDR_CHECK(ndr_push_uint32(ndr, 0)); + NDR_CHECK(ndr_push_uint32(ndr, len/2 - 1)); + NDR_CHECK(ndr_push_bytes(ndr, ws, len - 2)); + return NT_STATUS_OK; +} + /* pull a comformant, variable ucs2 string from the wire into a C string */ @@ -268,6 +287,14 @@ NTSTATUS ndr_pull_unistr(struct ndr_pull *ndr, const char **s) return NT_STATUS_OK; } +/* + pull a comformant, variable ucs2 string from the wire into a C string +*/ +NTSTATUS ndr_pull_unistr_noterm(struct ndr_pull *ndr, const char **s) +{ + return ndr_pull_unistr(ndr, s); +} + /* push a 4 byte offset pointer, remembering where we are so we can later fill in the correct value -- cgit From adf6142953c4fa81493f133d45eb80d91b069e47 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 9 Nov 2003 07:24:06 +0000 Subject: converted the rpcecho pipe to use IDL (This used to be commit 1b7a7bc4641e4f0e604bc20699c094fa5f49315d) --- source4/librpc/ndr/ndr_basic.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 6ada49997f..b8c0cffd6d 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -102,6 +102,20 @@ NTSTATUS ndr_pull_bytes(struct ndr_pull *ndr, char *data, uint32 n) return NT_STATUS_OK; } +/* + pull an array of uint8 +*/ +NTSTATUS ndr_pull_array_uint8(struct ndr_pull *ndr, char *data, uint32 n) +{ + uint32 len; + NDR_CHECK(ndr_pull_uint32(ndr, &len)); + if (len != n) { + return NT_STATUS_INVALID_PARAMETER; + } + return ndr_pull_bytes(ndr, data, len); +} + + /* parse a GUID */ @@ -179,6 +193,15 @@ NTSTATUS ndr_push_bytes(struct ndr_push *ndr, const char *data, uint32 n) return NT_STATUS_OK; } +/* + push an array of uint8 +*/ +NTSTATUS ndr_push_array_uint8(struct ndr_push *ndr, const char *data, uint32 n) +{ + NDR_CHECK(ndr_push_uint32(ndr, n)); + return ndr_push_bytes(ndr, data, n); +} + /* save the current position */ -- cgit From a934f89549b3d23199d68b7dc3fc3ad16e86b9ad Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 11 Nov 2003 02:02:29 +0000 Subject: started adding support for lsa_QueryInfoPolicy (This used to be commit 5b2d577969103ed5c633ea993d476787af14fa93) --- source4/librpc/ndr/ndr_basic.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index b8c0cffd6d..b6c5a0cd53 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -353,3 +353,23 @@ NTSTATUS ndr_push_guid(struct ndr_push *ndr, GUID *guid) { return ndr_push_bytes(ndr, guid->info, GUID_SIZE); } + +/* + push a NTTIME +*/ +NTSTATUS ndr_push_NTTIME(struct ndr_push *ndr, NTTIME t) +{ + NDR_CHECK(ndr_push_uint32(ndr, t.low)); + NDR_CHECK(ndr_push_uint32(ndr, t.high)); + return NT_STATUS_OK; +} + +/* + pull a NTTIME +*/ +NTSTATUS ndr_pull_NTTIME(struct ndr_pull *ndr, NTTIME *t) +{ + NDR_CHECK(ndr_pull_uint32(ndr, &t->low)); + NDR_CHECK(ndr_pull_uint32(ndr, &t->high)); + return NT_STATUS_OK; +} -- cgit From cecbf0cd8b99f7019a83def88baec889d6a06e6f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 11 Nov 2003 04:04:36 +0000 Subject: automatically generate ndr_print_*() functions for every IDL structure. This allows easy debug and test tool writing without having to write functions that print every element of complex structures. (This used to be commit 81d6181172e36c6fbae0907550a29511ce708574) --- source4/librpc/ndr/ndr_basic.c | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index b6c5a0cd53..11f3bb5e23 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -373,3 +373,48 @@ NTSTATUS ndr_pull_NTTIME(struct ndr_pull *ndr, NTTIME *t) NDR_CHECK(ndr_pull_uint32(ndr, &t->high)); return NT_STATUS_OK; } + + +void ndr_print_struct(struct ndr_print *ndr, const char *name) +{ + ndr->print(ndr, "%s:", name); +} + +void ndr_print_uint8(struct ndr_print *ndr, const char *name, uint8 v) +{ + ndr->print(ndr, "%-25s: 0x%02x (%u)", name, v, v); +} + +void ndr_print_uint16(struct ndr_print *ndr, const char *name, uint16 v) +{ + ndr->print(ndr, "%-25s: 0x%04x (%u)", name, v, v); +} + +void ndr_print_uint32(struct ndr_print *ndr, const char *name, uint32 v) +{ + ndr->print(ndr, "%-25s: 0x%08x (%u)", name, v, v); +} + +void ndr_print_ptr(struct ndr_print *ndr, const char *name, const void *p) +{ + if (p) { + ndr->print(ndr, "%-25s: *", name); + } else { + ndr->print(ndr, "%-25s: NULL", name); + } +} + +void ndr_print_unistr_noterm(struct ndr_print *ndr, const char *name, const char *s) +{ + ndr->print(ndr, "%-25s: '%s'", name, s); +} + +void ndr_print_unistr(struct ndr_print *ndr, const char *name, const char *s) +{ + ndr->print(ndr, "%-25s: '%s'", name, s); +} + +void ndr_print_NTTIME(struct ndr_print *ndr, const char *name, NTTIME t) +{ + ndr->print(ndr, "%-25s: %s", name, nt_time_string(ndr->mem_ctx, &t)); +} -- cgit From deeb8d98a10a0fb1dbeca13653a802cef43d9e07 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 11 Nov 2003 04:38:51 +0000 Subject: start using automatic union printing (This used to be commit e81040a902f67fd10ca1f9c9ca1c22bc95e36005) --- source4/librpc/ndr/ndr_basic.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 11f3bb5e23..2276b76e95 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -375,9 +375,9 @@ NTSTATUS ndr_pull_NTTIME(struct ndr_pull *ndr, NTTIME *t) } -void ndr_print_struct(struct ndr_print *ndr, const char *name) +void ndr_print_struct(struct ndr_print *ndr, const char *name, const char *type) { - ndr->print(ndr, "%s:", name); + ndr->print(ndr, "%s: struct %s", name, type); } void ndr_print_uint8(struct ndr_print *ndr, const char *name, uint8 v) @@ -418,3 +418,13 @@ void ndr_print_NTTIME(struct ndr_print *ndr, const char *name, NTTIME t) { ndr->print(ndr, "%-25s: %s", name, nt_time_string(ndr->mem_ctx, &t)); } + +void ndr_print_union(struct ndr_print *ndr, const char *name, uint16 level, const char *type) +{ + ndr->print(ndr, "%-25s: union %s(case %u)", name, type, level); +} + +void ndr_print_bad_level(struct ndr_print *ndr, const char *name, uint16 level) +{ + ndr->print(ndr, "UNKNOWN LEVEL %u", level); +} -- cgit From bde602b9e1192945d7c0139fd4226b431fc214f2 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 11 Nov 2003 06:22:58 +0000 Subject: support lsa_AuditEventsInfo (This used to be commit 7e7cb975936252083c5c02a64c00ee2667099c22) --- source4/librpc/ndr/ndr_basic.c | 51 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 2276b76e95..3cb9e38749 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -116,6 +116,39 @@ NTSTATUS ndr_pull_array_uint8(struct ndr_pull *ndr, char *data, uint32 n) } +/* + pull an array of uint16 +*/ +NTSTATUS ndr_pull_array_uint16(struct ndr_pull *ndr, uint16 *data, uint32 n) +{ + uint32 len, i; + NDR_CHECK(ndr_pull_uint32(ndr, &len)); + if (len != n) { + return NT_STATUS_INVALID_PARAMETER; + } + for (i=0;iprint(ndr, "UNKNOWN LEVEL %u", level); } + +void ndr_print_array_uint32(struct ndr_print *ndr, const char *name, + uint32 *data, uint32 count) +{ + int i; + + ndr->print(ndr, "%s: ARRAY(%d)", name, count); + ndr->depth++; + for (i=0;idepth--; +} -- cgit From c614ea5435e3a4c9b6e05dcde9daa7d38f7131ca Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 11 Nov 2003 06:54:54 +0000 Subject: added QueryPolicyInfo/PrimaryDomainInfo idl and test code (This used to be commit b754ad2eae517abacaa26d9e28a8bf6164274971) --- source4/librpc/ndr/ndr_basic.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 3cb9e38749..ec065f63cc 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -206,12 +206,15 @@ NTSTATUS ndr_push_uint32(struct ndr_push *ndr, uint32 v) return NT_STATUS_OK; } -/* - align to a uint32 -*/ -NTSTATUS ndr_push_align_uint32(struct ndr_push *ndr) +NTSTATUS ndr_push_align(struct ndr_push *ndr, size_t size) { - NDR_PUSH_ALIGN(ndr, 4); + NDR_PUSH_ALIGN(ndr, size); + return NT_STATUS_OK; +} + +NTSTATUS ndr_pull_align(struct ndr_pull *ndr, size_t size) +{ + NDR_PULL_ALIGN(ndr, size); return NT_STATUS_OK; } -- cgit From 8830a20bce4bde93aef2752c1e87aca428169d0a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 11 Nov 2003 07:57:08 +0000 Subject: added 9 more info levels to lsa_QueryInfoPolicy (This used to be commit b2ced24fc0be4944dd96f160e435f4c6773debcd) --- source4/librpc/ndr/ndr_basic.c | 57 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 7 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index ec065f63cc..a906e0c05b 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -80,6 +80,24 @@ NTSTATUS ndr_pull_uint32(struct ndr_pull *ndr, uint32 *v) return NT_STATUS_OK; } +/* + parse a HYPER_T +*/ +NTSTATUS ndr_pull_HYPER_T(struct ndr_pull *ndr, HYPER_T *v) +{ + NDR_PULL_ALIGN(ndr, 8); + NDR_PULL_NEED_BYTES(ndr, 8); + if (ndr->flags & LIBNDR_FLAG_BIGENDIAN) { + v->low = RIVAL(ndr->data, ndr->offset); + v->high = RIVAL(ndr->data, ndr->offset+4); + } else { + v->low = IVAL(ndr->data, ndr->offset); + v->high = IVAL(ndr->data, ndr->offset+4); + } + ndr->offset += 8; + return NT_STATUS_OK; +} + /* pull a NTSTATUS */ @@ -152,14 +170,11 @@ NTSTATUS ndr_pull_array_uint32(struct ndr_pull *ndr, uint32 *data, uint32 n) /* parse a GUID */ -NTSTATUS ndr_pull_guid(struct ndr_pull *ndr, GUID *guid) +NTSTATUS ndr_pull_GUID(struct ndr_pull *ndr, int ndr_flags, GUID *guid) { - int i; - NDR_PULL_NEED_BYTES(ndr, GUID_SIZE); - for (i=0;iinfo[i] = CVAL(ndr->data, ndr->offset + i); + if (ndr_flags & NDR_SCALARS) { + return ndr_pull_bytes(ndr, guid->info, GUID_SIZE); } - ndr->offset += i; return NT_STATUS_OK; } @@ -206,6 +221,19 @@ NTSTATUS ndr_push_uint32(struct ndr_push *ndr, uint32 v) return NT_STATUS_OK; } +/* + push a HYPER_T +*/ +NTSTATUS ndr_push_HYPER_T(struct ndr_push *ndr, HYPER_T v) +{ + NDR_PUSH_ALIGN(ndr, 8); + NDR_PUSH_NEED_BYTES(ndr, 8); + SIVAL(ndr->data, ndr->offset, v.low); + SIVAL(ndr->data, ndr->offset+4, v.high); + ndr->offset += 8; + return NT_STATUS_OK; +} + NTSTATUS ndr_push_align(struct ndr_push *ndr, size_t size) { NDR_PUSH_ALIGN(ndr, size); @@ -385,7 +413,7 @@ NTSTATUS ndr_push_offset_ptr(struct ndr_push *ndr, /* push a GUID */ -NTSTATUS ndr_push_guid(struct ndr_push *ndr, GUID *guid) +NTSTATUS ndr_push_GUID(struct ndr_push *ndr, GUID *guid) { return ndr_push_bytes(ndr, guid->info, GUID_SIZE); } @@ -431,6 +459,11 @@ void ndr_print_uint32(struct ndr_print *ndr, const char *name, uint32 v) ndr->print(ndr, "%-25s: 0x%08x (%u)", name, v, v); } +void ndr_print_HYPER_T(struct ndr_print *ndr, const char *name, HYPER_T v) +{ + ndr->print(ndr, "%-25s: 0x%08x%08x", name, v.high, v.low); +} + void ndr_print_ptr(struct ndr_print *ndr, const char *name, const void *p) { if (p) { @@ -482,3 +515,13 @@ void ndr_print_array_uint32(struct ndr_print *ndr, const char *name, } ndr->depth--; } + +void ndr_print_GUID(struct ndr_print *ndr, const char *name, struct GUID *guid) +{ + ndr->print(ndr, "%-25s: %08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + name, + IVAL(guid->info, 0), SVAL(guid->info, 4), SVAL(guid->info, 6), + guid->info[8], guid->info[9], + guid->info[10], guid->info[11], guid->info[12], guid->info[13], + guid->info[14], guid->info[15]); +} -- cgit From 6714815f014ae1b31d0675214d023e3afe2389f0 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 12 Nov 2003 05:34:21 +0000 Subject: lsa_PrivilegeSet seems to be a very strange beast indeed. It has a constant sized array of size 1 at the end? (This used to be commit 2cc354bd82456cb5598eb4acb40a5ada1459d08d) --- source4/librpc/ndr/ndr_basic.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index a906e0c05b..f1996b55f7 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -150,20 +150,29 @@ NTSTATUS ndr_pull_array_uint16(struct ndr_pull *ndr, uint16 *data, uint32 n) return NT_STATUS_OK; } +/* + pull a const array of uint32 +*/ +NTSTATUS ndr_pull_const_array_uint32(struct ndr_pull *ndr, uint32 *data, uint32 n) +{ + uint32 i; + for (i=0;i Date: Thu, 13 Nov 2003 09:26:53 +0000 Subject: * fixed conformant arrays in structures * expanded the rpcecho test * started adding the NETDFS pipe (This used to be commit 095ab42cbdd5c1c5ab753e2eb275742ba822c8b9) --- source4/librpc/ndr/ndr_basic.c | 51 ++++++------------------------------------ 1 file changed, 7 insertions(+), 44 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index f1996b55f7..a643f658c0 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -54,11 +54,7 @@ NTSTATUS ndr_pull_uint16(struct ndr_pull *ndr, uint16 *v) { NDR_PULL_ALIGN(ndr, 2); NDR_PULL_NEED_BYTES(ndr, 2); - if (ndr->flags & LIBNDR_FLAG_BIGENDIAN) { - *v = RSVAL(ndr->data, ndr->offset); - } else { - *v = SVAL(ndr->data, ndr->offset); - } + *v = SVAL(ndr->data, ndr->offset); ndr->offset += 2; return NT_STATUS_OK; } @@ -71,11 +67,7 @@ NTSTATUS ndr_pull_uint32(struct ndr_pull *ndr, uint32 *v) { NDR_PULL_ALIGN(ndr, 4); NDR_PULL_NEED_BYTES(ndr, 4); - if (ndr->flags & LIBNDR_FLAG_BIGENDIAN) { - *v = RIVAL(ndr->data, ndr->offset); - } else { - *v = IVAL(ndr->data, ndr->offset); - } + *v = IVAL(ndr->data, ndr->offset); ndr->offset += 4; return NT_STATUS_OK; } @@ -87,13 +79,8 @@ NTSTATUS ndr_pull_HYPER_T(struct ndr_pull *ndr, HYPER_T *v) { NDR_PULL_ALIGN(ndr, 8); NDR_PULL_NEED_BYTES(ndr, 8); - if (ndr->flags & LIBNDR_FLAG_BIGENDIAN) { - v->low = RIVAL(ndr->data, ndr->offset); - v->high = RIVAL(ndr->data, ndr->offset+4); - } else { - v->low = IVAL(ndr->data, ndr->offset); - v->high = IVAL(ndr->data, ndr->offset+4); - } + v->low = IVAL(ndr->data, ndr->offset); + v->high = IVAL(ndr->data, ndr->offset+4); ndr->offset += 8; return NT_STATUS_OK; } @@ -125,12 +112,7 @@ NTSTATUS ndr_pull_bytes(struct ndr_pull *ndr, char *data, uint32 n) */ NTSTATUS ndr_pull_array_uint8(struct ndr_pull *ndr, char *data, uint32 n) { - uint32 len; - NDR_CHECK(ndr_pull_uint32(ndr, &len)); - if (len != n) { - return NT_STATUS_INVALID_PARAMETER; - } - return ndr_pull_bytes(ndr, data, len); + return ndr_pull_bytes(ndr, data, n); } @@ -139,11 +121,7 @@ NTSTATUS ndr_pull_array_uint8(struct ndr_pull *ndr, char *data, uint32 n) */ NTSTATUS ndr_pull_array_uint16(struct ndr_pull *ndr, uint16 *data, uint32 n) { - uint32 len, i; - NDR_CHECK(ndr_pull_uint32(ndr, &len)); - if (len != n) { - return NT_STATUS_INVALID_PARAMETER; - } + uint32 i; for (i=0;i Date: Fri, 14 Nov 2003 07:20:46 +0000 Subject: we can now do a level1 NetDfsEnum() (This used to be commit f32641f73f7ff12b797378b3b533603ff1d526b5) --- source4/librpc/ndr/ndr_basic.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index a643f658c0..6208943d94 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -238,6 +238,18 @@ NTSTATUS ndr_push_array_uint8(struct ndr_push *ndr, const char *data, uint32 n) return ndr_push_bytes(ndr, data, n); } +/* + push an array of uint32 +*/ +NTSTATUS ndr_push_array_uint32(struct ndr_push *ndr, const uint32 *data, uint32 n) +{ + int i; + for (i=0;i Date: Fri, 14 Nov 2003 08:27:39 +0000 Subject: * added levels 4, 200 and 300 to NetDfsEnum. 200 and 300 don't work properly, I'm still investigating that. * changed dcerpc fault status code to NT_STATUS_NETWORK_WRITE_FAULT, which I think is a better mapping (This used to be commit 9ad28f6ddbb777de7cac11e71c392b508c81b741) --- source4/librpc/ndr/ndr_basic.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 6208943d94..b50b614b92 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -397,9 +397,12 @@ NTSTATUS ndr_push_offset_ptr(struct ndr_push *ndr, /* push a GUID */ -NTSTATUS ndr_push_GUID(struct ndr_push *ndr, GUID *guid) +NTSTATUS ndr_push_GUID(struct ndr_push *ndr, int ndr_flags, GUID *guid) { - return ndr_push_bytes(ndr, guid->info, GUID_SIZE); + if (ndr_flags & NDR_SCALARS) { + return ndr_push_bytes(ndr, guid->info, GUID_SIZE); + } + return NT_STATUS_OK; } /* -- cgit From 099899a7cc01fab5faba82e59650aa76bac8143e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 15 Nov 2003 04:42:48 +0000 Subject: added lsa_QuerySecObj() and the necessary sec_desc_buf supporting code also adding printing of security descriptors (This used to be commit 1f93cbc1d597b973ab1a5005ede093c1bcefff87) --- source4/librpc/ndr/ndr_basic.c | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index b50b614b92..89c16ca76a 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -22,19 +22,6 @@ #include "includes.h" -#define NDR_PULL_NEED_BYTES(ndr, n) do { \ - if ((n) > ndr->data_size || ndr->offset + (n) > ndr->data_size) { \ - return NT_STATUS_BUFFER_TOO_SMALL; \ - } \ -} while(0) - -#define NDR_PULL_ALIGN(ndr, n) do { \ - ndr->offset = (ndr->offset + (n-1)) & ~(n-1); \ - if (ndr->offset >= ndr->data_size) { \ - return NT_STATUS_BUFFER_TOO_SMALL; \ - } \ -} while(0) - /* parse a uint8 */ @@ -152,13 +139,6 @@ NTSTATUS ndr_pull_GUID(struct ndr_pull *ndr, int ndr_flags, GUID *guid) } -#define NDR_PUSH_NEED_BYTES(ndr, n) NDR_CHECK(ndr_push_expand(ndr, ndr->offset+(n))) - -#define NDR_PUSH_ALIGN(ndr, n) do { \ - uint32 _pad = (ndr->offset & (n-1)); \ - while (_pad--) NDR_CHECK(ndr_push_uint8(ndr, 0)); \ -} while(0) - /* push a uint8 */ -- cgit From e92419e2d35126f98af6c22fe5e0224421998aad Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 15 Nov 2003 10:58:29 +0000 Subject: added samr_UserInfo2 and samr_UserInfo3 (This used to be commit 5e852f694c039ae8bde3490be9e0c4959c1e93f0) --- source4/librpc/ndr/ndr_basic.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 89c16ca76a..6239e56b3f 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -483,6 +483,24 @@ void ndr_print_array_uint32(struct ndr_print *ndr, const char *name, ndr->depth--; } +void ndr_print_array_uint8(struct ndr_print *ndr, const char *name, + uint8 *data, uint32 count) +{ + int i; + + ndr->print(ndr, "%s: ARRAY(%d)", name, count); + ndr->depth++; + for (i=0;idepth--; +} + void ndr_print_GUID(struct ndr_print *ndr, const char *name, struct GUID *guid) { ndr->print(ndr, "%-25s: %08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", -- cgit From 7b40bd0a5f7adbca91ce42ae36bb4908a4515fa8 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 16 Nov 2003 06:00:15 +0000 Subject: use the "subcontext" magic flag for sec_desc_buf (This used to be commit 05ed2f6dc986111ce448123c91380f9340799ecc) --- source4/librpc/ndr/ndr_basic.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 6239e56b3f..31e16b6812 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -510,3 +510,5 @@ void ndr_print_GUID(struct ndr_print *ndr, const char *name, struct GUID *guid) guid->info[10], guid->info[11], guid->info[12], guid->info[13], guid->info[14], guid->info[15]); } + + -- cgit From ea266c0625e04a2dc10d25c2fee7b685965fcd3e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 16 Nov 2003 11:36:59 +0000 Subject: added support for level1 of EnumPrinters in spoolss. This uses a number of "magic" add-ons to IDL to make it less painful, hopefully this will make IDL generation useful for horrible systems like spoolss (This used to be commit e18dba7d5a957ef82e8f91733a0bf95d579dcd7a) --- source4/librpc/ndr/ndr_basic.c | 71 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 31e16b6812..ece496ebde 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -512,3 +512,74 @@ void ndr_print_GUID(struct ndr_print *ndr, const char *name, struct GUID *guid) } +/* + pull a spoolss style "relative string" +*/ +NTSTATUS ndr_pull_relstr(struct ndr_pull *ndr, int ndr_flags, const char **s) +{ + uint32 ofs; + int ret; + struct ndr_pull_save save; + + if (!(ndr_flags & NDR_SCALARS)) { + return NT_STATUS_OK; + } + + NDR_CHECK(ndr_pull_uint32(ndr, &ofs)); + ndr_pull_save(ndr, &save); + NDR_CHECK(ndr_pull_set_offset(ndr, ofs)); + ret = convert_string_talloc(ndr->mem_ctx, CH_UCS2, CH_UNIX, + ndr->data+ndr->offset, + ndr->data_size - ndr->offset, + (const void **)s); + if (ret == -1) { + return ndr_pull_error(ndr, NDR_ERR_RELSTR, "Bad relative string"); + } + ndr_pull_restore(ndr, &save); + return NT_STATUS_OK; +} + +/* + push a spoolss style "relative string" +*/ +NTSTATUS ndr_push_relstr(struct ndr_push *ndr, int ndr_flags, const char **s) +{ + struct ndr_push_save *save; + if (ndr_flags & NDR_SCALARS) { + save = talloc(ndr->mem_ctx, sizeof(*save)); + if (!save) return NT_STATUS_NO_MEMORY; + NDR_CHECK(ndr_push_align(ndr, 4)); + ndr_push_save(ndr, save); + NDR_CHECK(ndr_push_uint32(ndr, 0xFFFFFFFF)); + save->next = ndr->relstr_list; + ndr->relstr_list = save; + } + if (ndr_flags & NDR_BUFFERS) { + struct ndr_push_save save2; + uint32 len; + int ret; + save = ndr->relstr_list; + if (!save) { + return ndr_push_error(ndr, NDR_ERR_RELSTR, "Empty relstr stack"); + } + ndr->relstr_list = save->next; + NDR_CHECK(ndr_push_align(ndr, 2)); + ndr_push_save(ndr, &save2); + ndr_push_restore(ndr, save); + NDR_CHECK(ndr_push_uint32(ndr, save2.offset)); + ndr_push_restore(ndr, &save2); + len = 2*(strlen_m(*s)+1); + NDR_PUSH_NEED_BYTES(ndr, len); + ret = push_ucs2(NULL, ndr->data + ndr->offset, *s, len, STR_TERMINATE); + if (ret == -1) { + return ndr_push_error(ndr, NDR_ERR_CHARCNV, "Bad string conversion"); + } + ndr->offset += len; + } + return NT_STATUS_OK; +} + +void ndr_print_relstr(struct ndr_print *ndr, const char *name, const char **s) +{ + ndr_print_unistr(ndr, name, *s); +} -- cgit From ae4cb40100a5c04a4604acfde989ce96ef1801bd Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 16 Nov 2003 13:49:14 +0000 Subject: use nstring and [relative] to support levels 1 and 2 of EnumPrinters fully (This used to be commit 69c6017c945bdd7d1945f22fcad49112ba6a2d2d) --- source4/librpc/ndr/ndr_basic.c | 65 ++++++++++++++---------------------------- 1 file changed, 21 insertions(+), 44 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index ece496ebde..408d041e3c 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -466,7 +466,7 @@ void ndr_print_bad_level(struct ndr_print *ndr, const char *name, uint16 level) } void ndr_print_array_uint32(struct ndr_print *ndr, const char *name, - uint32 *data, uint32 count) + const uint32 *data, uint32 count) { int i; @@ -484,7 +484,7 @@ void ndr_print_array_uint32(struct ndr_print *ndr, const char *name, } void ndr_print_array_uint8(struct ndr_print *ndr, const char *name, - uint8 *data, uint32 count) + const uint8 *data, uint32 count) { int i; @@ -501,7 +501,7 @@ void ndr_print_array_uint8(struct ndr_print *ndr, const char *name, ndr->depth--; } -void ndr_print_GUID(struct ndr_print *ndr, const char *name, struct GUID *guid) +void ndr_print_GUID(struct ndr_print *ndr, const char *name, const struct GUID *guid) { ndr->print(ndr, "%-25s: %08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", name, @@ -513,73 +513,50 @@ void ndr_print_GUID(struct ndr_print *ndr, const char *name, struct GUID *guid) /* - pull a spoolss style "relative string" + pull a null terminated UCS2 string */ -NTSTATUS ndr_pull_relstr(struct ndr_pull *ndr, int ndr_flags, const char **s) +NTSTATUS ndr_pull_nstring(struct ndr_pull *ndr, int ndr_flags, const char **s) { - uint32 ofs; int ret; - struct ndr_pull_save save; if (!(ndr_flags & NDR_SCALARS)) { return NT_STATUS_OK; } - NDR_CHECK(ndr_pull_uint32(ndr, &ofs)); - ndr_pull_save(ndr, &save); - NDR_CHECK(ndr_pull_set_offset(ndr, ofs)); ret = convert_string_talloc(ndr->mem_ctx, CH_UCS2, CH_UNIX, ndr->data+ndr->offset, ndr->data_size - ndr->offset, (const void **)s); if (ret == -1) { - return ndr_pull_error(ndr, NDR_ERR_RELSTR, "Bad relative string"); + return ndr_pull_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); } - ndr_pull_restore(ndr, &save); + ndr->offset += ret; return NT_STATUS_OK; } /* push a spoolss style "relative string" */ -NTSTATUS ndr_push_relstr(struct ndr_push *ndr, int ndr_flags, const char **s) +NTSTATUS ndr_push_nstring(struct ndr_push *ndr, int ndr_flags, const char **s) { - struct ndr_push_save *save; - if (ndr_flags & NDR_SCALARS) { - save = talloc(ndr->mem_ctx, sizeof(*save)); - if (!save) return NT_STATUS_NO_MEMORY; - NDR_CHECK(ndr_push_align(ndr, 4)); - ndr_push_save(ndr, save); - NDR_CHECK(ndr_push_uint32(ndr, 0xFFFFFFFF)); - save->next = ndr->relstr_list; - ndr->relstr_list = save; + uint32 len; + int ret; + + if (!(ndr_flags & NDR_SCALARS)) { + return NT_STATUS_OK; } - if (ndr_flags & NDR_BUFFERS) { - struct ndr_push_save save2; - uint32 len; - int ret; - save = ndr->relstr_list; - if (!save) { - return ndr_push_error(ndr, NDR_ERR_RELSTR, "Empty relstr stack"); - } - ndr->relstr_list = save->next; - NDR_CHECK(ndr_push_align(ndr, 2)); - ndr_push_save(ndr, &save2); - ndr_push_restore(ndr, save); - NDR_CHECK(ndr_push_uint32(ndr, save2.offset)); - ndr_push_restore(ndr, &save2); - len = 2*(strlen_m(*s)+1); - NDR_PUSH_NEED_BYTES(ndr, len); - ret = push_ucs2(NULL, ndr->data + ndr->offset, *s, len, STR_TERMINATE); - if (ret == -1) { - return ndr_push_error(ndr, NDR_ERR_CHARCNV, "Bad string conversion"); - } - ndr->offset += len; + + len = 2*(strlen_m(*s)+1); + NDR_PUSH_NEED_BYTES(ndr, len); + ret = push_ucs2(NULL, ndr->data + ndr->offset, *s, len, STR_TERMINATE); + if (ret == -1) { + return ndr_push_error(ndr, NDR_ERR_CHARCNV, "Bad string conversion"); } + ndr->offset += len; return NT_STATUS_OK; } -void ndr_print_relstr(struct ndr_print *ndr, const char *name, const char **s) +void ndr_print_nstring(struct ndr_print *ndr, const char *name, const char **s) { ndr_print_unistr(ndr, name, *s); } -- cgit From 657b4d2abdad5691fc37bafe819f75cc440354b9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 17 Nov 2003 02:18:11 +0000 Subject: nicer method of handling spoolss EnumPrinters this also handles the return of several printers (an array of relative subcontexts) (This used to be commit 060421c7dc9aa611fe4160843a4f76498ab16bf4) --- source4/librpc/ndr/ndr_basic.c | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 408d041e3c..2c6a3aac96 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -440,14 +440,18 @@ void ndr_print_ptr(struct ndr_print *ndr, const char *name, const void *p) } } -void ndr_print_unistr_noterm(struct ndr_print *ndr, const char *name, const char *s) +void ndr_print_unistr(struct ndr_print *ndr, const char *name, const char *s) { - ndr->print(ndr, "%-25s: '%s'", name, s); + if (s) { + ndr->print(ndr, "%-25s: '%s'", name, s); + } else { + ndr->print(ndr, "%-25s: NULL", name); + } } -void ndr_print_unistr(struct ndr_print *ndr, const char *name, const char *s) +void ndr_print_unistr_noterm(struct ndr_print *ndr, const char *name, const char *s) { - ndr->print(ndr, "%-25s: '%s'", name, s); + ndr_print_unistr(ndr, name, s); } void ndr_print_NTTIME(struct ndr_print *ndr, const char *name, NTTIME t) @@ -560,3 +564,27 @@ void ndr_print_nstring(struct ndr_print *ndr, const char *name, const char **s) { ndr_print_unistr(ndr, name, *s); } + + +/* + push a DATA_BLOB onto the wire. +*/ +NTSTATUS ndr_push_DATA_BLOB(struct ndr_push *ndr, DATA_BLOB blob) +{ + NDR_CHECK(ndr_push_uint32(ndr, blob.length)); + NDR_CHECK(ndr_push_bytes(ndr, blob.data, blob.length)); + return NT_STATUS_OK; +} + +/* + pull a DATA_BLOB from the wire. +*/ +NTSTATUS ndr_pull_DATA_BLOB(struct ndr_pull *ndr, DATA_BLOB *blob) +{ + uint32 length; + NDR_CHECK(ndr_pull_uint32(ndr, &length)); + NDR_PULL_NEED_BYTES(ndr, length); + *blob = data_blob_talloc(ndr->mem_ctx, ndr->data+ndr->offset, length); + ndr->offset += length; + return NT_STATUS_OK; +} -- cgit From 90916de4a5303601a59938237a551d976cde0589 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 17 Nov 2003 02:58:10 +0000 Subject: * more info levels for EnumPrinter * use WERROR return type in spoolss EnumPrinter (This used to be commit 8301a6b6ad45f76a42d0fcab6347c187eee615a9) --- source4/librpc/ndr/ndr_basic.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 2c6a3aac96..8e90fc990f 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -83,6 +83,17 @@ NTSTATUS ndr_pull_NTSTATUS(struct ndr_pull *ndr, NTSTATUS *status) return NT_STATUS_OK; } +/* + pull a WERROR +*/ +NTSTATUS ndr_pull_WERROR(struct ndr_pull *ndr, WERROR *status) +{ + uint32 v; + NDR_CHECK(ndr_pull_uint32(ndr, &v)); + *status = W_ERROR(v); + return NT_STATUS_OK; +} + /* parse a set of bytes */ -- cgit From 59df3ce5b5c5b484793a0e16faeb581ef343e167 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 17 Nov 2003 06:27:45 +0000 Subject: security descriptors are no longer a "special" type, they are handled using the [relative] property this also fixes level3 of PrinterInfo (a relative secdesc) (This used to be commit d5a15257fdd5f6cfe2706765a7c29f623ec1c6f8) --- source4/librpc/ndr/ndr_basic.c | 46 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 8e90fc990f..ee03e5aaa2 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -108,8 +108,11 @@ NTSTATUS ndr_pull_bytes(struct ndr_pull *ndr, char *data, uint32 n) /* pull an array of uint8 */ -NTSTATUS ndr_pull_array_uint8(struct ndr_pull *ndr, char *data, uint32 n) +NTSTATUS ndr_pull_array_uint8(struct ndr_pull *ndr, int ndr_flags, char *data, uint32 n) { + if (!(ndr_flags & NDR_SCALARS)) { + return NT_STATUS_OK; + } return ndr_pull_bytes(ndr, data, n); } @@ -117,9 +120,12 @@ NTSTATUS ndr_pull_array_uint8(struct ndr_pull *ndr, char *data, uint32 n) /* pull an array of uint16 */ -NTSTATUS ndr_pull_array_uint16(struct ndr_pull *ndr, uint16 *data, uint32 n) +NTSTATUS ndr_pull_array_uint16(struct ndr_pull *ndr, int ndr_flags, uint16 *data, uint32 n) { uint32 i; + if (!(ndr_flags & NDR_SCALARS)) { + return NT_STATUS_OK; + } for (i=0;ioffset += length; return NT_STATUS_OK; } + + +/* + parse a policy handle +*/ +NTSTATUS ndr_pull_policy_handle(struct ndr_pull *ndr, + struct policy_handle *r) +{ + NDR_CHECK(ndr_pull_bytes(ndr, r->data, 20)); + return NT_STATUS_OK; +} + +/* + push a policy handle +*/ +NTSTATUS ndr_push_policy_handle(struct ndr_push *ndr, + struct policy_handle *r) +{ + NDR_CHECK(ndr_push_bytes(ndr, r->data, 20)); + return NT_STATUS_OK; +} -- cgit From d285c6f14f7ad7037e1a81d59da8b3c892a49884 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 17 Nov 2003 11:55:56 +0000 Subject: * add another WERR err code * use the top-level function argument printing to show more detail in RPC-* tests (This used to be commit 33bb8785625b1845750f28f2d810e7096afe9f8e) --- source4/librpc/ndr/ndr_basic.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index ee03e5aaa2..3d87b9efc6 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -591,6 +591,11 @@ void ndr_print_nstring(struct ndr_print *ndr, const char *name, const char **s) ndr_print_unistr(ndr, name, *s); } +void ndr_print_DATA_BLOB(struct ndr_print *ndr, const char *name, DATA_BLOB r) +{ + ndr->print(ndr, "%-25s: DATA_BLOB length=%u", name, r.length); +} + /* push a DATA_BLOB onto the wire. @@ -635,3 +640,14 @@ NTSTATUS ndr_push_policy_handle(struct ndr_push *ndr, NDR_CHECK(ndr_push_bytes(ndr, r->data, 20)); return NT_STATUS_OK; } + + +void ndr_print_policy_handle(struct ndr_print *ndr, const char *name, struct policy_handle *r) +{ + ndr->print(ndr, "%-25s: policy_handle %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", + name, + r->data[0], r->data[1], r->data[2], r->data[3], r->data[4], + r->data[5], r->data[6], r->data[7], r->data[8], r->data[9], + r->data[10], r->data[11], r->data[12], r->data[13], r->data[14], + r->data[15], r->data[16], r->data[17], r->data[18], r->data[19]); +} -- cgit From 2c0a7165efb1ce52be27bd13496e99c5e5c70e48 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 18 Nov 2003 01:18:24 +0000 Subject: * use the new auto-generated debug code method. * add a couple more info levels to wkssvc (This used to be commit c69161bdb13745f271b0cfa9a9af349f7a95edc6) --- source4/librpc/ndr/ndr_basic.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 3d87b9efc6..a2f0309acd 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -83,6 +83,11 @@ NTSTATUS ndr_pull_NTSTATUS(struct ndr_pull *ndr, NTSTATUS *status) return NT_STATUS_OK; } +void ndr_print_NTSTATUS(struct ndr_print *ndr, const char *name, NTSTATUS *r) +{ + ndr->print(ndr, "%-25s: %s", name, nt_errstr(*r)); +} + /* pull a WERROR */ @@ -94,6 +99,11 @@ NTSTATUS ndr_pull_WERROR(struct ndr_pull *ndr, WERROR *status) return NT_STATUS_OK; } +void ndr_print_WERROR(struct ndr_print *ndr, const char *name, WERROR *r) +{ + ndr->print(ndr, "%-25s: %s", name, win_errstr(*r)); +} + /* parse a set of bytes */ -- cgit From f01e89e9e0800df912b5ee87bcacb664daa0895e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 20 Nov 2003 01:28:33 +0000 Subject: EnumPrinterData in spoolss now works (This used to be commit af07ca7fbcb4118f2415218d0c48798119b7c6b2) --- source4/librpc/ndr/ndr_basic.c | 66 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index a2f0309acd..fcf64b6790 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -574,6 +574,37 @@ NTSTATUS ndr_pull_nstring(struct ndr_pull *ndr, int ndr_flags, const char **s) return NT_STATUS_OK; } +/* + pull a length prefixed UCS2 string +*/ +NTSTATUS ndr_pull_lstring(struct ndr_pull *ndr, int ndr_flags, const char **s) +{ + int ret; + uint32 size; + + if (!(ndr_flags & NDR_SCALARS)) { + return NT_STATUS_OK; + } + + NDR_CHECK(ndr_pull_uint32(ndr, &size)); + if (size == 0) { + *s = NULL; + return NT_STATUS_OK; + } + + NDR_PULL_NEED_BYTES(ndr, size*2); + + ret = convert_string_talloc(ndr->mem_ctx, CH_UCS2, CH_UNIX, + ndr->data+ndr->offset, + size*2, + (const void **)s); + if (ret == -1) { + return ndr_pull_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); + } + ndr->offset += size*2; + return NT_STATUS_OK; +} + /* push a spoolss style "relative string" */ @@ -596,11 +627,46 @@ NTSTATUS ndr_push_nstring(struct ndr_push *ndr, int ndr_flags, const char **s) return NT_STATUS_OK; } +/* + push a length prefixed ucs2 string +*/ +NTSTATUS ndr_push_lstring(struct ndr_push *ndr, int ndr_flags, const char **s) +{ + uint32 len; + int ret; + + if (!(ndr_flags & NDR_SCALARS)) { + return NT_STATUS_OK; + } + + if (! *s) { + NDR_CHECK(ndr_push_uint32(ndr, 0)); + return NT_STATUS_OK; + } + + len = (strlen_m(*s)+1); + + NDR_CHECK(ndr_push_uint32(ndr, len)); + NDR_PUSH_NEED_BYTES(ndr, len*2); + + ret = push_ucs2(NULL, ndr->data + ndr->offset, *s, len*2, STR_TERMINATE); + if (ret == -1) { + return ndr_push_error(ndr, NDR_ERR_CHARCNV, "Bad string conversion"); + } + ndr->offset += len*2; + return NT_STATUS_OK; +} + void ndr_print_nstring(struct ndr_print *ndr, const char *name, const char **s) { ndr_print_unistr(ndr, name, *s); } +void ndr_print_lstring(struct ndr_print *ndr, const char *name, const char **s) +{ + ndr_print_unistr(ndr, name, *s); +} + void ndr_print_DATA_BLOB(struct ndr_print *ndr, const char *name, DATA_BLOB r) { ndr->print(ndr, "%-25s: DATA_BLOB length=%u", name, r.length); -- cgit From 308cc429eb7c07d94609f2818e9d81239cb4cbb9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 20 Nov 2003 03:09:19 +0000 Subject: added samr_LookupNames() and test code (This used to be commit f8397cbc8554b721093b8ae6ac6fb26d0ee9a7cf) --- source4/librpc/ndr/ndr_basic.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index fcf64b6790..0cb4456399 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -308,7 +308,15 @@ NTSTATUS ndr_push_length4_end(struct ndr_push *ndr, struct ndr_push_save *save) */ NTSTATUS ndr_push_ptr(struct ndr_push *ndr, const void *p) { - return ndr_push_uint32(ndr, p?0xaabbccdd:0); + uint32 ptr = 0; + if (p) { + /* we do this to ensure that we generate unique ref ids, + which means we can handle the case where a MS programmer + forgot to mark a pointer as unique */ + ndr->ptr_count++; + ptr = 0xaabbcc00 + ndr->ptr_count; + } + return ndr_push_uint32(ndr, ptr); } /* -- cgit From 38ce2ef4bb05b463f1a3484665c88ae55bbd7b72 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 21 Nov 2003 02:19:47 +0000 Subject: added 4 more levels to samr_QueryDisplayInfo() (This used to be commit f4cc593a5c7d75adaced2c33dd83c2ec741751be) --- source4/librpc/ndr/ndr_basic.c | 65 ++++++++++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 21 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 0cb4456399..49cff11480 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -337,6 +337,22 @@ NTSTATUS ndr_push_unistr(struct ndr_push *ndr, const char *s) return NT_STATUS_OK; } +/* + push a comformant, variable ascii string onto the wire from a C string + TODO: need to look at what charset this should be in +*/ +NTSTATUS ndr_push_ascstr(struct ndr_push *ndr, const char *s) +{ + ssize_t len = s?strlen(s):0; + NDR_CHECK(ndr_push_uint32(ndr, len)); + NDR_CHECK(ndr_push_uint32(ndr, 0)); + NDR_CHECK(ndr_push_uint32(ndr, len?len+1:0)); + if (s) { + NDR_CHECK(ndr_push_bytes(ndr, s, len)); + } + return NT_STATUS_OK; +} + /* push a comformant, variable ucs2 string onto the wire from a C string don't send the null @@ -382,6 +398,29 @@ NTSTATUS ndr_pull_unistr(struct ndr_pull *ndr, const char **s) return NT_STATUS_OK; } +/* + pull a comformant, variable ascii string from the wire into a C string + TODO: check what charset this is in +*/ +NTSTATUS ndr_pull_ascstr(struct ndr_pull *ndr, const char **s) +{ + uint32 len1, ofs, len2; + char *as; + + NDR_CHECK(ndr_pull_uint32(ndr, &len1)); + NDR_CHECK(ndr_pull_uint32(ndr, &ofs)); + NDR_CHECK(ndr_pull_uint32(ndr, &len2)); + if (len2 > len1) { + return NT_STATUS_INVALID_PARAMETER; + } + NDR_ALLOC_N(ndr, as, (len1+1)); + NDR_CHECK(ndr_pull_bytes(ndr, as, len2)); + as[len2] = 0; + as[len1] = 0; + (*s) = as; + return NT_STATUS_OK; +} + /* pull a comformant, variable ucs2 string from the wire into a C string */ @@ -498,6 +537,11 @@ void ndr_print_unistr_noterm(struct ndr_print *ndr, const char *name, const char ndr_print_unistr(ndr, name, s); } +void ndr_print_ascstr(struct ndr_print *ndr, const char *name, const char *s) +{ + ndr_print_unistr(ndr, name, s); +} + void ndr_print_NTTIME(struct ndr_print *ndr, const char *name, NTTIME t) { ndr->print(ndr, "%-25s: %s", name, nt_time_string(ndr->mem_ctx, &t)); @@ -705,27 +749,6 @@ NTSTATUS ndr_pull_DATA_BLOB(struct ndr_pull *ndr, DATA_BLOB *blob) } -/* - parse a policy handle -*/ -NTSTATUS ndr_pull_policy_handle(struct ndr_pull *ndr, - struct policy_handle *r) -{ - NDR_CHECK(ndr_pull_bytes(ndr, r->data, 20)); - return NT_STATUS_OK; -} - -/* - push a policy handle -*/ -NTSTATUS ndr_push_policy_handle(struct ndr_push *ndr, - struct policy_handle *r) -{ - NDR_CHECK(ndr_push_bytes(ndr, r->data, 20)); - return NT_STATUS_OK; -} - - void ndr_print_policy_handle(struct ndr_print *ndr, const char *name, struct policy_handle *r) { ndr->print(ndr, "%-25s: policy_handle %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", -- cgit From a465add90f3291f022104600c6221e8d90287e64 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 21 Nov 2003 13:14:17 +0000 Subject: * changed the way strings are handled in pidl to a much more general interface. We now support an arbitrary set of flags to each parser, and these can be used to control the string types. I have provided some common IDL string types in librpc/idl/idl_types.h which needs to be included in every IDL file. * added IDL for the endpoint mapper. Added a test suite that enumerates all endpoints on the server. (This used to be commit d2665f36a75b482ff82733f72ffac938c2acf87a) --- source4/librpc/ndr/ndr_basic.c | 408 +++++++++++++++++++---------------------- 1 file changed, 191 insertions(+), 217 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 49cff11480..56c0ab231e 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -314,119 +314,219 @@ NTSTATUS ndr_push_ptr(struct ndr_push *ndr, const void *p) which means we can handle the case where a MS programmer forgot to mark a pointer as unique */ ndr->ptr_count++; - ptr = 0xaabbcc00 + ndr->ptr_count; + ptr = ndr->ptr_count; } return ndr_push_uint32(ndr, ptr); } -/* - push a comformant, variable ucs2 string onto the wire from a C string -*/ -NTSTATUS ndr_push_unistr(struct ndr_push *ndr, const char *s) -{ - char *ws; - ssize_t len; - len = push_ucs2_talloc(ndr->mem_ctx, (smb_ucs2_t **)&ws, s); - if (len == -1) { - return NT_STATUS_INVALID_PARAMETER; - } - NDR_CHECK(ndr_push_uint32(ndr, len/2)); - NDR_CHECK(ndr_push_uint32(ndr, 0)); - NDR_CHECK(ndr_push_uint32(ndr, len/2)); - NDR_CHECK(ndr_push_bytes(ndr, ws, len)); - return NT_STATUS_OK; -} /* - push a comformant, variable ascii string onto the wire from a C string - TODO: need to look at what charset this should be in + pull a general string from the wire */ -NTSTATUS ndr_push_ascstr(struct ndr_push *ndr, const char *s) +NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) { - ssize_t len = s?strlen(s):0; - NDR_CHECK(ndr_push_uint32(ndr, len)); - NDR_CHECK(ndr_push_uint32(ndr, 0)); - NDR_CHECK(ndr_push_uint32(ndr, len?len+1:0)); - if (s) { - NDR_CHECK(ndr_push_bytes(ndr, s, len)); + char *as=NULL; + uint32 len1, ofs, len2; + int ret; + + if (!(ndr_flags & NDR_SCALARS)) { + return NT_STATUS_OK; } - return NT_STATUS_OK; -} -/* - push a comformant, variable ucs2 string onto the wire from a C string - don't send the null -*/ -NTSTATUS ndr_push_unistr_noterm(struct ndr_push *ndr, const char *s) -{ - char *ws; - ssize_t len; - len = push_ucs2_talloc(ndr->mem_ctx, (smb_ucs2_t **)&ws, s); - if (len == -1) { - return NT_STATUS_INVALID_PARAMETER; + switch (ndr->flags & LIBNDR_STRING_FLAGS) { + case LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4: + case LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_NOTERM: + NDR_CHECK(ndr_pull_uint32(ndr, &len1)); + NDR_CHECK(ndr_pull_uint32(ndr, &ofs)); + NDR_CHECK(ndr_pull_uint32(ndr, &len2)); + if (len2 > len1) { + return NT_STATUS_INVALID_PARAMETER; + } + if (len2 == 0) { + *s = talloc_strdup(ndr->mem_ctx, ""); + break; + } + NDR_PULL_NEED_BYTES(ndr, len2*2); + ret = convert_string_talloc(ndr->mem_ctx, CH_UCS2, CH_UNIX, + ndr->data+ndr->offset, + len2*2, + (const void **)&as); + if (ret == -1) { + return ndr_pull_error(ndr, NDR_ERR_CHARCNV, + "Bad character conversion"); + } + NDR_CHECK(ndr_pull_advance(ndr, len2*2)); + *s = as; + break; + + case LIBNDR_FLAG_STR_SIZE4: + NDR_CHECK(ndr_pull_uint32(ndr, &len1)); + NDR_PULL_NEED_BYTES(ndr, len1*2); + if (len1 == 0) { + *s = talloc_strdup(ndr->mem_ctx, ""); + break; + } + ret = convert_string_talloc(ndr->mem_ctx, CH_UCS2, CH_UNIX, + ndr->data+ndr->offset, + len1*2, + (const void **)&as); + if (ret == -1) { + return ndr_pull_error(ndr, NDR_ERR_CHARCNV, + "Bad character conversion"); + } + NDR_CHECK(ndr_pull_advance(ndr, len1*2)); + *s = as; + break; + + case LIBNDR_FLAG_STR_NULLTERM: + ret = convert_string_talloc(ndr->mem_ctx, CH_UCS2, CH_UNIX, + ndr->data+ndr->offset, + ndr->data_size - ndr->offset, + (const void **)s); + if (ret == -1) { + return ndr_pull_error(ndr, NDR_ERR_CHARCNV, + "Bad character conversion"); + } + NDR_CHECK(ndr_pull_advance(ndr, ret)); + break; + + case LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4: + NDR_CHECK(ndr_pull_uint32(ndr, &len1)); + NDR_CHECK(ndr_pull_uint32(ndr, &ofs)); + NDR_CHECK(ndr_pull_uint32(ndr, &len2)); + if (len2 > len1) { + return NT_STATUS_INVALID_PARAMETER; + } + NDR_ALLOC_N(ndr, as, (len2+1)); + NDR_CHECK(ndr_pull_bytes(ndr, as, len2)); + as[len2] = 0; + (*s) = as; + break; + + case LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_LEN4: + NDR_CHECK(ndr_pull_uint32(ndr, &ofs)); + NDR_CHECK(ndr_pull_uint32(ndr, &len2)); + NDR_ALLOC_N(ndr, as, (len2+1)); + NDR_CHECK(ndr_pull_bytes(ndr, as, len2)); + as[len2] = 0; + (*s) = as; + break; + + default: + return ndr_pull_error(ndr, NDR_ERR_STRING, "Bad string flags 0x%x\n", + ndr->flags & LIBNDR_STRING_FLAGS); } - NDR_CHECK(ndr_push_uint32(ndr, len/2 - 1)); - NDR_CHECK(ndr_push_uint32(ndr, 0)); - NDR_CHECK(ndr_push_uint32(ndr, len/2 - 1)); - NDR_CHECK(ndr_push_bytes(ndr, ws, len - 2)); + return NT_STATUS_OK; } + /* - pull a comformant, variable ucs2 string from the wire into a C string + push a general string onto the wire */ -NTSTATUS ndr_pull_unistr(struct ndr_pull *ndr, const char **s) +NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) { - char *ws, *as=NULL; - uint32 len1, ofs, len2; + ssize_t s_len, c_len; + int ret; - NDR_CHECK(ndr_pull_uint32(ndr, &len1)); - NDR_CHECK(ndr_pull_uint32(ndr, &ofs)); - NDR_CHECK(ndr_pull_uint32(ndr, &len2)); - if (len2 > len1) { - return NT_STATUS_INVALID_PARAMETER; - } - NDR_ALLOC_N(ndr, ws, (len1+1)*2); - NDR_CHECK(ndr_pull_bytes(ndr, ws, len2*2)); - SSVAL(ws, len1*2, 0); - SSVAL(ws, len2*2, 0); - pull_ucs2_talloc(ndr->mem_ctx, &as, (const smb_ucs2_t *)ws); - if (!as) { - return NT_STATUS_INVALID_PARAMETER; + if (!(ndr_flags & NDR_SCALARS)) { + return NT_STATUS_OK; } - *s = as; - return NT_STATUS_OK; -} + + s_len = s?strlen(s):0; + c_len = s?strlen_m(s):0; -/* - pull a comformant, variable ascii string from the wire into a C string - TODO: check what charset this is in -*/ -NTSTATUS ndr_pull_ascstr(struct ndr_pull *ndr, const char **s) -{ - uint32 len1, ofs, len2; - char *as; + switch (ndr->flags & LIBNDR_STRING_FLAGS) { + case LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4: + NDR_CHECK(ndr_push_uint32(ndr, c_len+1)); + NDR_CHECK(ndr_push_uint32(ndr, 0)); + NDR_CHECK(ndr_push_uint32(ndr, c_len+1)); + NDR_PUSH_NEED_BYTES(ndr, c_len*2 + 2); + ret = convert_string(CH_UNIX, CH_UCS2, + s, s_len+1, + ndr->data+ndr->offset, c_len*2 + 2); + if (ret == -1) { + return ndr_push_error(ndr, NDR_ERR_CHARCNV, + "Bad character conversion"); + } + ndr->offset += c_len*2 + 2; + break; + + case LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_NOTERM: + NDR_CHECK(ndr_push_uint32(ndr, c_len)); + NDR_CHECK(ndr_push_uint32(ndr, 0)); + NDR_CHECK(ndr_push_uint32(ndr, c_len)); + NDR_PUSH_NEED_BYTES(ndr, c_len*2); + ret = convert_string(CH_UNIX, CH_UCS2, + s, s_len, + ndr->data+ndr->offset, c_len*2); + if (ret == -1) { + return ndr_push_error(ndr, NDR_ERR_CHARCNV, + "Bad character conversion"); + } + ndr->offset += c_len*2; + break; + + case LIBNDR_FLAG_STR_SIZE4: + NDR_CHECK(ndr_push_uint32(ndr, c_len + 1)); + NDR_PUSH_NEED_BYTES(ndr, c_len*2 + 2); + ret = convert_string(CH_UNIX, CH_UCS2, + s, s_len + 1, + ndr->data+ndr->offset, c_len*2 + 2); + if (ret == -1) { + return ndr_push_error(ndr, NDR_ERR_CHARCNV, + "Bad character conversion"); + } + ndr->offset += c_len*2 + 2; + break; + + case LIBNDR_FLAG_STR_NULLTERM: + NDR_PUSH_NEED_BYTES(ndr, c_len*2 + 2); + ret = convert_string(CH_UNIX, CH_UCS2, + s, s_len+1, + ndr->data+ndr->offset, c_len*2 + 2); + if (ret == -1) { + return ndr_push_error(ndr, NDR_ERR_CHARCNV, + "Bad character conversion"); + } + ndr->offset += c_len*2 + 2; + break; + + case LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4: + NDR_CHECK(ndr_push_uint32(ndr, c_len+1)); + NDR_CHECK(ndr_push_uint32(ndr, 0)); + NDR_CHECK(ndr_push_uint32(ndr, c_len+1)); + NDR_PUSH_NEED_BYTES(ndr, c_len + 1); + ret = convert_string(CH_UNIX, CH_DOS, + s, s_len + 1, + ndr->data+ndr->offset, c_len + 1); + if (ret == -1) { + return ndr_push_error(ndr, NDR_ERR_CHARCNV, + "Bad character conversion"); + } + ndr->offset += c_len + 1; + break; + + case LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_LEN4: + NDR_CHECK(ndr_push_uint32(ndr, 0)); + NDR_CHECK(ndr_push_uint32(ndr, c_len+1)); + NDR_PUSH_NEED_BYTES(ndr, c_len + 1); + ret = convert_string(CH_UNIX, CH_DOS, + s, s_len + 1, + ndr->data+ndr->offset, c_len + 1); + if (ret == -1) { + return ndr_push_error(ndr, NDR_ERR_CHARCNV, + "Bad character conversion"); + } + ndr->offset += c_len + 1; + break; - NDR_CHECK(ndr_pull_uint32(ndr, &len1)); - NDR_CHECK(ndr_pull_uint32(ndr, &ofs)); - NDR_CHECK(ndr_pull_uint32(ndr, &len2)); - if (len2 > len1) { - return NT_STATUS_INVALID_PARAMETER; + default: + return ndr_push_error(ndr, NDR_ERR_STRING, "Bad string flags 0x%x\n", + ndr->flags & LIBNDR_STRING_FLAGS); } - NDR_ALLOC_N(ndr, as, (len1+1)); - NDR_CHECK(ndr_pull_bytes(ndr, as, len2)); - as[len2] = 0; - as[len1] = 0; - (*s) = as; - return NT_STATUS_OK; -} -/* - pull a comformant, variable ucs2 string from the wire into a C string -*/ -NTSTATUS ndr_pull_unistr_noterm(struct ndr_pull *ndr, const char **s) -{ - return ndr_pull_unistr(ndr, s); + return NT_STATUS_OK; } /* @@ -523,7 +623,7 @@ void ndr_print_ptr(struct ndr_print *ndr, const char *name, const void *p) } } -void ndr_print_unistr(struct ndr_print *ndr, const char *name, const char *s) +void ndr_print_string(struct ndr_print *ndr, const char *name, const char *s) { if (s) { ndr->print(ndr, "%-25s: '%s'", name, s); @@ -532,16 +632,6 @@ void ndr_print_unistr(struct ndr_print *ndr, const char *name, const char *s) } } -void ndr_print_unistr_noterm(struct ndr_print *ndr, const char *name, const char *s) -{ - ndr_print_unistr(ndr, name, s); -} - -void ndr_print_ascstr(struct ndr_print *ndr, const char *name, const char *s) -{ - ndr_print_unistr(ndr, name, s); -} - void ndr_print_NTTIME(struct ndr_print *ndr, const char *name, NTTIME t) { ndr->print(ndr, "%-25s: %s", name, nt_time_string(ndr->mem_ctx, &t)); @@ -603,122 +693,6 @@ void ndr_print_GUID(struct ndr_print *ndr, const char *name, const struct GUID * guid->info[14], guid->info[15]); } - -/* - pull a null terminated UCS2 string -*/ -NTSTATUS ndr_pull_nstring(struct ndr_pull *ndr, int ndr_flags, const char **s) -{ - int ret; - - if (!(ndr_flags & NDR_SCALARS)) { - return NT_STATUS_OK; - } - - ret = convert_string_talloc(ndr->mem_ctx, CH_UCS2, CH_UNIX, - ndr->data+ndr->offset, - ndr->data_size - ndr->offset, - (const void **)s); - if (ret == -1) { - return ndr_pull_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); - } - ndr->offset += ret; - return NT_STATUS_OK; -} - -/* - pull a length prefixed UCS2 string -*/ -NTSTATUS ndr_pull_lstring(struct ndr_pull *ndr, int ndr_flags, const char **s) -{ - int ret; - uint32 size; - - if (!(ndr_flags & NDR_SCALARS)) { - return NT_STATUS_OK; - } - - NDR_CHECK(ndr_pull_uint32(ndr, &size)); - if (size == 0) { - *s = NULL; - return NT_STATUS_OK; - } - - NDR_PULL_NEED_BYTES(ndr, size*2); - - ret = convert_string_talloc(ndr->mem_ctx, CH_UCS2, CH_UNIX, - ndr->data+ndr->offset, - size*2, - (const void **)s); - if (ret == -1) { - return ndr_pull_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); - } - ndr->offset += size*2; - return NT_STATUS_OK; -} - -/* - push a spoolss style "relative string" -*/ -NTSTATUS ndr_push_nstring(struct ndr_push *ndr, int ndr_flags, const char **s) -{ - uint32 len; - int ret; - - if (!(ndr_flags & NDR_SCALARS)) { - return NT_STATUS_OK; - } - - len = 2*(strlen_m(*s)+1); - NDR_PUSH_NEED_BYTES(ndr, len); - ret = push_ucs2(NULL, ndr->data + ndr->offset, *s, len, STR_TERMINATE); - if (ret == -1) { - return ndr_push_error(ndr, NDR_ERR_CHARCNV, "Bad string conversion"); - } - ndr->offset += len; - return NT_STATUS_OK; -} - -/* - push a length prefixed ucs2 string -*/ -NTSTATUS ndr_push_lstring(struct ndr_push *ndr, int ndr_flags, const char **s) -{ - uint32 len; - int ret; - - if (!(ndr_flags & NDR_SCALARS)) { - return NT_STATUS_OK; - } - - if (! *s) { - NDR_CHECK(ndr_push_uint32(ndr, 0)); - return NT_STATUS_OK; - } - - len = (strlen_m(*s)+1); - - NDR_CHECK(ndr_push_uint32(ndr, len)); - NDR_PUSH_NEED_BYTES(ndr, len*2); - - ret = push_ucs2(NULL, ndr->data + ndr->offset, *s, len*2, STR_TERMINATE); - if (ret == -1) { - return ndr_push_error(ndr, NDR_ERR_CHARCNV, "Bad string conversion"); - } - ndr->offset += len*2; - return NT_STATUS_OK; -} - -void ndr_print_nstring(struct ndr_print *ndr, const char *name, const char **s) -{ - ndr_print_unistr(ndr, name, *s); -} - -void ndr_print_lstring(struct ndr_print *ndr, const char *name, const char **s) -{ - ndr_print_unistr(ndr, name, *s); -} - void ndr_print_DATA_BLOB(struct ndr_print *ndr, const char *name, DATA_BLOB r) { ndr->print(ndr, "%-25s: DATA_BLOB length=%u", name, r.length); -- cgit From 86a604429ee13aa8c3f930ea74b1fada278ced45 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 22 Nov 2003 08:11:32 +0000 Subject: a fairly major upgrade to the dcerpc system * added a NDR validator. The way it works is that when the DCERPC_DEBUG_VALIDATE_* flags are set the dcerpc system will perform NDR buffer validation. On sending a request the packet is first marshalled, then unmarahslled, then marshalled again, and it is confirmed that the two marshalling results are idential. This ensures that our pull and push routines are absolutely in sync, so that we can be very confident that if a routine works in the client then the corresponding routine must work on the server side. A similar validation is performed on all replies. * a result of this change is that pidl is fussier about the [ref] tag. You can only use it on pointers (which is the only place it makes sense) * fixed a basic alignment bug in the push side of the NDR code * added server side pull/push support. Our dcerpc system is now fully ready to be used on the server side. * fixed the relative offset pointer list. It must be traversed in reverse order on push * added automatic value setting for the size parameter in outgoing SdBuf structures. * expanded the ndr debugging code to always give a message on any failure * fixed the subcontext push code * fixed some memory leaks in smbtorture RPC tests (This used to be commit 8ecf720206a2eef3f8ea7cbdb1f460664a5dba9a) --- source4/librpc/ndr/ndr_basic.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 56c0ab231e..a3c4bc0aec 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -83,6 +83,14 @@ NTSTATUS ndr_pull_NTSTATUS(struct ndr_pull *ndr, NTSTATUS *status) return NT_STATUS_OK; } +/* + push a NTSTATUS +*/ +NTSTATUS ndr_push_NTSTATUS(struct ndr_push *ndr, NTSTATUS status) +{ + return ndr_push_uint32(ndr, NT_STATUS_V(status)); +} + void ndr_print_NTSTATUS(struct ndr_print *ndr, const char *name, NTSTATUS *r) { ndr->print(ndr, "%-25s: %s", name, nt_errstr(*r)); @@ -99,6 +107,14 @@ NTSTATUS ndr_pull_WERROR(struct ndr_pull *ndr, WERROR *status) return NT_STATUS_OK; } +/* + push a WERROR +*/ +NTSTATUS ndr_push_WERROR(struct ndr_push *ndr, WERROR status) +{ + return ndr_push_uint32(ndr, W_ERROR_V(status)); +} + void ndr_print_WERROR(struct ndr_print *ndr, const char *name, WERROR *r) { ndr->print(ndr, "%-25s: %s", name, win_errstr(*r)); @@ -340,7 +356,9 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) NDR_CHECK(ndr_pull_uint32(ndr, &ofs)); NDR_CHECK(ndr_pull_uint32(ndr, &len2)); if (len2 > len1) { - return NT_STATUS_INVALID_PARAMETER; + return ndr_pull_error(ndr, NDR_ERR_STRING, + "Bad string lengths len1=%u ofs=%u len2=%u\n", + len1, ofs, len2); } if (len2 == 0) { *s = talloc_strdup(ndr->mem_ctx, ""); @@ -395,7 +413,9 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) NDR_CHECK(ndr_pull_uint32(ndr, &ofs)); NDR_CHECK(ndr_pull_uint32(ndr, &len2)); if (len2 > len1) { - return NT_STATUS_INVALID_PARAMETER; + return ndr_pull_error(ndr, NDR_ERR_STRING, + "Bad ascii string lengths len1=%u ofs=%u len2=%u\n", + len1, ofs, len2); } NDR_ALLOC_N(ndr, as, (len2+1)); NDR_CHECK(ndr_pull_bytes(ndr, as, len2)); -- cgit From be77d9c60d17e0ef2ed0b51ea0814c42a41a40a3 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 22 Nov 2003 11:49:22 +0000 Subject: * fixed null terminated string handling * fixed nested relative offsets in push functions the spoolss torture test now passes! (This used to be commit 60ced76160e4f4e2b511ebbeec31130c8ebcdd22) --- source4/librpc/ndr/ndr_basic.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index a3c4bc0aec..4d0be44a89 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -397,15 +397,20 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) break; case LIBNDR_FLAG_STR_NULLTERM: + len1 = strnlen_w(ndr->data+ndr->offset, + (ndr->data_size - ndr->offset)/2); + if (len1*2+2 <= ndr->data_size - ndr->offset) { + len1++; + } ret = convert_string_talloc(ndr->mem_ctx, CH_UCS2, CH_UNIX, ndr->data+ndr->offset, - ndr->data_size - ndr->offset, + len1*2, (const void **)s); if (ret == -1) { return ndr_pull_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); } - NDR_CHECK(ndr_pull_advance(ndr, ret)); + NDR_CHECK(ndr_pull_advance(ndr, len1*2)); break; case LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4: -- cgit From 800d3e0134b72135fa359fa5a239f1c68adf4ca1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 23 Nov 2003 06:28:12 +0000 Subject: ooh, this is fun! I have recoded the core dcerpc packet structures (all the PDUs etc) in terms of IDL, which means we now use pidl to generate all the code for handling the most basic dcerpc packets. This is not normally possible as it isn't completely valid NDR, but pidl has a number of extensions that make it quite easy. This also means we get the server side dcerpc marshalling/unmarshalling code for free. (This used to be commit 92bcad02587c3c1b31b523ee9fa46658a6cef9ff) --- source4/librpc/ndr/ndr_basic.c | 54 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 4d0be44a89..081d9ff87a 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -343,6 +343,7 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) { char *as=NULL; uint32 len1, ofs, len2; + uint16 len3; int ret; if (!(ndr_flags & NDR_SCALARS)) { @@ -437,6 +438,14 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) (*s) = as; break; + case LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_SIZE2: + NDR_CHECK(ndr_pull_uint16(ndr, &len3)); + NDR_ALLOC_N(ndr, as, (len3+1)); + NDR_CHECK(ndr_pull_bytes(ndr, as, len3)); + as[len3] = 0; + (*s) = as; + break; + default: return ndr_pull_error(ndr, NDR_ERR_STRING, "Bad string flags 0x%x\n", ndr->flags & LIBNDR_STRING_FLAGS); @@ -546,6 +555,19 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) ndr->offset += c_len + 1; break; + case LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_SIZE2: + NDR_CHECK(ndr_push_uint16(ndr, c_len+1)); + NDR_PUSH_NEED_BYTES(ndr, c_len + 1); + ret = convert_string(CH_UNIX, CH_DOS, + s, s_len + 1, + ndr->data+ndr->offset, c_len + 1); + if (ret == -1) { + return ndr_push_error(ndr, NDR_ERR_CHARCNV, + "Bad character conversion"); + } + ndr->offset += c_len + 1; + break; + default: return ndr_push_error(ndr, NDR_ERR_STRING, "Bad string flags 0x%x\n", ndr->flags & LIBNDR_STRING_FLAGS); @@ -729,7 +751,19 @@ void ndr_print_DATA_BLOB(struct ndr_print *ndr, const char *name, DATA_BLOB r) */ NTSTATUS ndr_push_DATA_BLOB(struct ndr_push *ndr, DATA_BLOB blob) { - NDR_CHECK(ndr_push_uint32(ndr, blob.length)); + if (ndr->flags & LIBNDR_ALIGN_FLAGS) { + if (ndr->flags & LIBNDR_FLAG_ALIGN2) { + blob.length = NDR_ALIGN(ndr, 2); + } else if (ndr->flags & LIBNDR_FLAG_ALIGN4) { + blob.length = NDR_ALIGN(ndr, 4); + } else if (ndr->flags & LIBNDR_FLAG_ALIGN8) { + blob.length = NDR_ALIGN(ndr, 8); + } + NDR_PUSH_ALLOC_SIZE(ndr, blob.data, blob.length); + data_blob_clear(&blob); + } else if (!(ndr->flags & LIBNDR_FLAG_REMAINING)) { + NDR_CHECK(ndr_push_uint32(ndr, blob.length)); + } NDR_CHECK(ndr_push_bytes(ndr, blob.data, blob.length)); return NT_STATUS_OK; } @@ -740,7 +774,23 @@ NTSTATUS ndr_push_DATA_BLOB(struct ndr_push *ndr, DATA_BLOB blob) NTSTATUS ndr_pull_DATA_BLOB(struct ndr_pull *ndr, DATA_BLOB *blob) { uint32 length; - NDR_CHECK(ndr_pull_uint32(ndr, &length)); + + if (ndr->flags & LIBNDR_ALIGN_FLAGS) { + if (ndr->flags & LIBNDR_FLAG_ALIGN2) { + length = NDR_ALIGN(ndr, 2); + } else if (ndr->flags & LIBNDR_FLAG_ALIGN4) { + length = NDR_ALIGN(ndr, 4); + } else if (ndr->flags & LIBNDR_FLAG_ALIGN8) { + length = NDR_ALIGN(ndr, 8); + } + if (ndr->data_size - ndr->offset < length) { + length = ndr->data_size - ndr->offset; + } + } else if (ndr->flags & LIBNDR_FLAG_REMAINING) { + length = ndr->data_size - ndr->offset; + } else { + NDR_CHECK(ndr_pull_uint32(ndr, &length)); + } NDR_PULL_NEED_BYTES(ndr, length); *blob = data_blob_talloc(ndr->mem_ctx, ndr->data+ndr->offset, length); ndr->offset += length; -- cgit From c7fd83d0b280810f16f7ef99ba58efb007f93920 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 24 Nov 2003 01:24:29 +0000 Subject: added the dcerpc remote management interfaces as mgmt.idl, and wrote a test suite. The test suite dumps all of the interfaces available on all pipes. There sure are a lot more interfaces on w2k3 than w2k ! (This used to be commit f94bc079902d725b63155d8d2de5bf408c6e7335) --- source4/librpc/ndr/ndr_basic.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 081d9ff87a..5f59899133 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -730,14 +730,21 @@ void ndr_print_array_uint8(struct ndr_print *ndr, const char *name, ndr->depth--; } +const char *GUID_string(TALLOC_CTX *mem_ctx, const struct GUID *guid) +{ + return talloc_asprintf(mem_ctx, + "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + IVAL(guid->info, 0), SVAL(guid->info, 4), + SVAL(guid->info, 6), + guid->info[8], guid->info[9], + guid->info[10], guid->info[11], + guid->info[12], guid->info[13], + guid->info[14], guid->info[15]); +} + void ndr_print_GUID(struct ndr_print *ndr, const char *name, const struct GUID *guid) { - ndr->print(ndr, "%-25s: %08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", - name, - IVAL(guid->info, 0), SVAL(guid->info, 4), SVAL(guid->info, 6), - guid->info[8], guid->info[9], - guid->info[10], guid->info[11], guid->info[12], guid->info[13], - guid->info[14], guid->info[15]); + ndr->print(ndr, "%-25s: %s", GUID_string(ndr->mem_ctx, guid)); } void ndr_print_DATA_BLOB(struct ndr_print *ndr, const char *name, DATA_BLOB r) -- cgit From e4773b184cd6ccf1e46ec151afbfd9fb9ad3ede8 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 24 Nov 2003 03:21:49 +0000 Subject: added tests for the remaining calls on the rpc management interface (This used to be commit 00f9b0e12061c175334f96805ca8333f28f74d91) --- source4/librpc/ndr/ndr_basic.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 5f59899133..a45771ef28 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -730,6 +730,38 @@ void ndr_print_array_uint8(struct ndr_print *ndr, const char *name, ndr->depth--; } +/* + build a GUID from a string +*/ +NTSTATUS GUID_from_string(const char *s, struct GUID *guid) +{ + uint32 time_low; + uint32 time_mid, time_hi_and_version; + uint32 clock_seq_hi_and_reserved; + uint32 clock_seq_low; + uint32 node[6]; + int i; + + if (11 != sscanf(s, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + &time_low, &time_mid, &time_hi_and_version, + &clock_seq_hi_and_reserved, &clock_seq_low, + &node[0], &node[1], &node[2], &node[3], &node[4], &node[5])) { + return NT_STATUS_INVALID_PARAMETER; + } + + SIVAL(guid->info, 0, time_low); + SSVAL(guid->info, 4, time_mid); + SSVAL(guid->info, 6, time_hi_and_version); + SCVAL(guid->info, 8, clock_seq_hi_and_reserved); + SCVAL(guid->info, 9, clock_seq_low); + for (i=0;i<6;i++) { + SCVAL(guid->info, 10 + i, node[i]); + } + + return NT_STATUS_OK; +} + + const char *GUID_string(TALLOC_CTX *mem_ctx, const struct GUID *guid) { return talloc_asprintf(mem_ctx, -- cgit From f5fe95abd203cc0506bcf7e94690d102d854ba0e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 24 Nov 2003 10:15:17 +0000 Subject: added tests for epm_Map endpointer map calls (This used to be commit 570ad78525ffcc116842270b62ba41c86c2a018d) --- source4/librpc/ndr/ndr_basic.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index a45771ef28..1f78bc17b6 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -782,6 +782,9 @@ void ndr_print_GUID(struct ndr_print *ndr, const char *name, const struct GUID * void ndr_print_DATA_BLOB(struct ndr_print *ndr, const char *name, DATA_BLOB r) { ndr->print(ndr, "%-25s: DATA_BLOB length=%u", name, r.length); + if (r.length) { + dump_data(10, r.data, r.length); + } } -- cgit From e0ac659917066dbf7f8fdbcc7684ce2b49dd04d9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 26 Nov 2003 01:16:41 +0000 Subject: signed DCERPC over TCP now works ! * moved ntlmssp code into libcli/auth/, and updated to latest ntlmssp code from samba3 (thanks Andrew! the new interface is great) * added signing/ntlmssp support in the dcerpc code * added a dcerpc_auth.c module for the various dcerpc auth mechanisms (This used to be commit c18c9b5585a3e5f7868562820c14f7cb529cdbcd) --- source4/librpc/ndr/ndr_basic.c | 64 +++++++++--------------------------------- 1 file changed, 14 insertions(+), 50 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 1f78bc17b6..52f4d29428 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -256,6 +256,17 @@ NTSTATUS ndr_push_bytes(struct ndr_push *ndr, const char *data, uint32 n) return NT_STATUS_OK; } +/* + push some zero bytes +*/ +NTSTATUS ndr_push_zero(struct ndr_push *ndr, uint32 n) +{ + NDR_PUSH_NEED_BYTES(ndr, n); + memset(ndr->data + ndr->offset, 0, n); + ndr->offset += n; + return NT_STATUS_OK; +} + /* push an array of uint8 */ @@ -298,27 +309,6 @@ void ndr_push_restore(struct ndr_push *ndr, struct ndr_push_save *save) ndr->offset = save->offset; } -/* - this is used when a packet has a 4 byte length field. We remember the start position - and come back to it later to fill in the size -*/ -NTSTATUS ndr_push_length4_start(struct ndr_push *ndr, struct ndr_push_save *save) -{ - NDR_PUSH_ALIGN(ndr, 4); - ndr_push_save(ndr, save); - return ndr_push_uint32(ndr, 0); -} - -NTSTATUS ndr_push_length4_end(struct ndr_push *ndr, struct ndr_push_save *save) -{ - struct ndr_push_save save2; - ndr_push_save(ndr, &save2); - ndr_push_restore(ndr, save); - NDR_CHECK(ndr_push_uint32(ndr, save2.offset - ndr->offset)); - ndr_push_restore(ndr, &save2); - return NT_STATUS_OK; -} - /* push a 1 if a pointer is non-NULL, otherwise 0 */ @@ -576,34 +566,6 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) return NT_STATUS_OK; } -/* - push a 4 byte offset pointer, remembering where we are so we can later fill - in the correct value -*/ -NTSTATUS ndr_push_offset(struct ndr_push *ndr, struct ndr_push_save *ofs) -{ - NDR_PUSH_ALIGN(ndr, 4); - ndr_push_save(ndr, ofs); - return ndr_push_uint32(ndr, 0); -} - -/* - fill in the correct offset in a saved offset pointer - the offset is taken relative to 'save' -*/ -NTSTATUS ndr_push_offset_ptr(struct ndr_push *ndr, - struct ndr_push_save *ofs, - struct ndr_push_save *save) -{ - struct ndr_push_save save2; - ndr_push_save(ndr, &save2); - ndr_push_restore(ndr, ofs); - NDR_CHECK(ndr_push_uint32(ndr, save2.offset - save->offset)); - ndr_push_restore(ndr, &save2); - return NT_STATUS_OK; -} - - /* push a GUID */ @@ -761,7 +723,9 @@ NTSTATUS GUID_from_string(const char *s, struct GUID *guid) return NT_STATUS_OK; } - +/* + its useful to be able to display these in debugging messages +*/ const char *GUID_string(TALLOC_CTX *mem_ctx, const struct GUID *guid) { return talloc_asprintf(mem_ctx, -- cgit From b0531a38cc7135538d251440ac4fc2c887d9f335 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 1 Dec 2003 01:41:38 +0000 Subject: started adding netlogon IDL and test suite (This used to be commit 3d64eefb464d09fb6e84d6139f801887a278cf86) --- source4/librpc/ndr/ndr_basic.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 52f4d29428..32cc7bac5f 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -597,6 +597,25 @@ NTSTATUS ndr_pull_NTTIME(struct ndr_pull *ndr, NTTIME *t) return NT_STATUS_OK; } +/* + push a time_t +*/ +NTSTATUS ndr_push_time_t(struct ndr_push *ndr, time_t t) +{ + return ndr_push_uint32(ndr, t); +} + +/* + pull a time_t +*/ +NTSTATUS ndr_pull_time_t(struct ndr_pull *ndr, time_t *t) +{ + uint32 tt; + NDR_CHECK(ndr_pull_uint32(ndr, &tt)); + *t = tt; + return NT_STATUS_OK; +} + void ndr_print_struct(struct ndr_print *ndr, const char *name, const char *type) { @@ -646,6 +665,15 @@ void ndr_print_NTTIME(struct ndr_print *ndr, const char *name, NTTIME t) ndr->print(ndr, "%-25s: %s", name, nt_time_string(ndr->mem_ctx, &t)); } +void ndr_print_time_t(struct ndr_print *ndr, const char *name, time_t t) +{ + if (t == (time_t)-1 || t == 0) { + ndr->print(ndr, "%-25s: (time_t)%d", name, (int)t); + } else { + ndr->print(ndr, "%-25s: %s", name, http_timestring(ndr->mem_ctx, t)); + } +} + void ndr_print_union(struct ndr_print *ndr, const char *name, uint16 level, const char *type) { ndr->print(ndr, "%-25s: union %s(case %u)", name, type, level); -- cgit From 5b46116923fb7c2945db128736b7f8113ea1a160 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 1 Dec 2003 03:19:43 +0000 Subject: added netr_ServerReqChallenge and cleaned up byte array printing (This used to be commit bb42107dccf3a384a4a5c029b4d2752e0898d7cb) --- source4/librpc/ndr/ndr_basic.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 32cc7bac5f..0300bdd3fb 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -707,6 +707,16 @@ void ndr_print_array_uint8(struct ndr_print *ndr, const char *name, { int i; + if (count <= 32 && (ndr->flags & LIBNDR_PRINT_ARRAY_HEX)) { + char s[65]; + for (i=0;iprint(ndr, "%-25s: %s", name, s); + return; + } + ndr->print(ndr, "%s: ARRAY(%d)", name, count); ndr->depth++; for (i=0;ioffset += length; return NT_STATUS_OK; } - - -void ndr_print_policy_handle(struct ndr_print *ndr, const char *name, struct policy_handle *r) -{ - ndr->print(ndr, "%-25s: policy_handle %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", - name, - r->data[0], r->data[1], r->data[2], r->data[3], r->data[4], - r->data[5], r->data[6], r->data[7], r->data[8], r->data[9], - r->data[10], r->data[11], r->data[12], r->data[13], r->data[14], - r->data[15], r->data[16], r->data[17], r->data[18], r->data[19]); -} -- cgit From d68d1558f7b6344a14774ce49ebc5da210a5b261 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 12 Dec 2003 06:26:34 +0000 Subject: Added routines for arrays of uint16s. (This used to be commit 370512f6644507ed0457de71ab5a50207e00e750) --- source4/librpc/ndr/ndr_basic.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 0300bdd3fb..3b5aea60ca 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -278,6 +278,21 @@ NTSTATUS ndr_push_array_uint8(struct ndr_push *ndr, int ndr_flags, const char *d return ndr_push_bytes(ndr, data, n); } +/* + push an array of uint16 +*/ +NTSTATUS ndr_push_array_uint16(struct ndr_push *ndr, int ndr_flags, const uint16 *data, uint32 n) +{ + int i; + if (!(ndr_flags & NDR_SCALARS)) { + return NT_STATUS_OK; + } + for (i=0;idepth--; } +void ndr_print_array_uint16(struct ndr_print *ndr, const char *name, + const uint16 *data, uint32 count) +{ + int i; + + ndr->print(ndr, "%s: ARRAY(%d)", name, count); + ndr->depth++; + for (i=0;idepth--; +} + void ndr_print_array_uint8(struct ndr_print *ndr, const char *name, const uint8 *data, uint32 count) { -- cgit From 24c22aef90d8534ee2d016b37b2b302f1367d106 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 16 Dec 2003 09:02:58 +0000 Subject: a fairly large commit! This adds support for bigendian rpc in the client. I have installed SUN pcnetlink locally and am using it to test the samba4 rpc code. This allows us to easily find places where we have stuffed up the types (such as 2 uint16 versus a uint32), as testing both big-endian and little-endian easily shows which is correct. I have now used this to fix several bugs like that in the samba4 IDL. In order to make this work I also had to redefine a GUID as a true structure, not a blob. From the pcnetlink wire it is clear that it is indeed defined as a structure (the byte order changes). This required changing lots of Samba code to use a GUID as a structure. I also had to fix the if_version code in dcerpc syntax IDs, as it turns out they are a single uint32 not two uint16s. The big-endian support is a bit ugly at the moment, and breaks the layering in some places. More work is needed, especially on the server side. (This used to be commit bb1af644a5a7b188290ce36232f255da0e5d66d2) --- source4/librpc/ndr/ndr_basic.c | 77 ++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 47 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 3b5aea60ca..ed75b8c27c 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -22,6 +22,12 @@ #include "includes.h" +#define NDR_BE(ndr) ((ndr)->flags & LIBNDR_FLAG_BIGENDIAN) +#define NDR_SVAL(ndr, ofs) (NDR_BE(ndr)?RSVAL(ndr->data,ofs):SVAL(ndr->data,ofs)) +#define NDR_IVAL(ndr, ofs) (NDR_BE(ndr)?RIVAL(ndr->data,ofs):IVAL(ndr->data,ofs)) +#define NDR_SSVAL(ndr, ofs, v) do { if (NDR_BE(ndr)) { RSSVAL(ndr->data,ofs,v); } else SSVAL(ndr->data,ofs,v); } while (0) +#define NDR_SIVAL(ndr, ofs, v) do { if (NDR_BE(ndr)) { RSIVAL(ndr->data,ofs,v); } else SIVAL(ndr->data,ofs,v); } while (0) + /* parse a uint8 */ @@ -41,7 +47,7 @@ NTSTATUS ndr_pull_uint16(struct ndr_pull *ndr, uint16 *v) { NDR_PULL_ALIGN(ndr, 2); NDR_PULL_NEED_BYTES(ndr, 2); - *v = SVAL(ndr->data, ndr->offset); + *v = NDR_SVAL(ndr, ndr->offset); ndr->offset += 2; return NT_STATUS_OK; } @@ -54,7 +60,7 @@ NTSTATUS ndr_pull_uint32(struct ndr_pull *ndr, uint32 *v) { NDR_PULL_ALIGN(ndr, 4); NDR_PULL_NEED_BYTES(ndr, 4); - *v = IVAL(ndr->data, ndr->offset); + *v = NDR_IVAL(ndr, ndr->offset); ndr->offset += 4; return NT_STATUS_OK; } @@ -66,8 +72,8 @@ NTSTATUS ndr_pull_HYPER_T(struct ndr_pull *ndr, HYPER_T *v) { NDR_PULL_ALIGN(ndr, 8); NDR_PULL_NEED_BYTES(ndr, 8); - v->low = IVAL(ndr->data, ndr->offset); - v->high = IVAL(ndr->data, ndr->offset+4); + v->low = NDR_IVAL(ndr, ndr->offset); + v->high = NDR_IVAL(ndr, ndr->offset+4); ndr->offset += 8; return NT_STATUS_OK; } @@ -173,18 +179,6 @@ NTSTATUS ndr_pull_array_uint32(struct ndr_pull *ndr, int ndr_flags, uint32 *data return NT_STATUS_OK; } -/* - parse a GUID -*/ -NTSTATUS ndr_pull_GUID(struct ndr_pull *ndr, int ndr_flags, GUID *guid) -{ - if (ndr_flags & NDR_SCALARS) { - return ndr_pull_bytes(ndr, guid->info, GUID_SIZE); - } - return NT_STATUS_OK; -} - - /* push a uint8 */ @@ -203,7 +197,7 @@ NTSTATUS ndr_push_uint16(struct ndr_push *ndr, uint16 v) { NDR_PUSH_ALIGN(ndr, 2); NDR_PUSH_NEED_BYTES(ndr, 2); - SSVAL(ndr->data, ndr->offset, v); + NDR_SSVAL(ndr, ndr->offset, v); ndr->offset += 2; return NT_STATUS_OK; } @@ -215,7 +209,7 @@ NTSTATUS ndr_push_uint32(struct ndr_push *ndr, uint32 v) { NDR_PUSH_ALIGN(ndr, 4); NDR_PUSH_NEED_BYTES(ndr, 4); - SIVAL(ndr->data, ndr->offset, v); + NDR_SIVAL(ndr, ndr->offset, v); ndr->offset += 4; return NT_STATUS_OK; } @@ -227,8 +221,8 @@ NTSTATUS ndr_push_HYPER_T(struct ndr_push *ndr, HYPER_T v) { NDR_PUSH_ALIGN(ndr, 8); NDR_PUSH_NEED_BYTES(ndr, 8); - SIVAL(ndr->data, ndr->offset, v.low); - SIVAL(ndr->data, ndr->offset+4, v.high); + NDR_SIVAL(ndr, ndr->offset, v.low); + NDR_SIVAL(ndr, ndr->offset+4, v.high); ndr->offset += 8; return NT_STATUS_OK; } @@ -581,17 +575,6 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) return NT_STATUS_OK; } -/* - push a GUID -*/ -NTSTATUS ndr_push_GUID(struct ndr_push *ndr, int ndr_flags, GUID *guid) -{ - if (ndr_flags & NDR_SCALARS) { - return ndr_push_bytes(ndr, guid->info, GUID_SIZE); - } - return NT_STATUS_OK; -} - /* push a NTTIME */ @@ -770,26 +753,25 @@ NTSTATUS GUID_from_string(const char *s, struct GUID *guid) { uint32 time_low; uint32 time_mid, time_hi_and_version; - uint32 clock_seq_hi_and_reserved; - uint32 clock_seq_low; + uint32 clock_seq[2]; uint32 node[6]; int i; if (11 != sscanf(s, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", &time_low, &time_mid, &time_hi_and_version, - &clock_seq_hi_and_reserved, &clock_seq_low, + &clock_seq[0], &clock_seq[1], &node[0], &node[1], &node[2], &node[3], &node[4], &node[5])) { return NT_STATUS_INVALID_PARAMETER; } - SIVAL(guid->info, 0, time_low); - SSVAL(guid->info, 4, time_mid); - SSVAL(guid->info, 6, time_hi_and_version); - SCVAL(guid->info, 8, clock_seq_hi_and_reserved); - SCVAL(guid->info, 9, clock_seq_low); + guid->time_low = time_low; + guid->time_mid = time_mid; + guid->time_hi_and_version = time_hi_and_version; + guid->clock_seq[0] = clock_seq[0]; + guid->clock_seq[1] = clock_seq[1]; for (i=0;i<6;i++) { - SCVAL(guid->info, 10 + i, node[i]); - } + guid->node[i] = node[i]; + } return NT_STATUS_OK; } @@ -801,12 +783,13 @@ const char *GUID_string(TALLOC_CTX *mem_ctx, const struct GUID *guid) { return talloc_asprintf(mem_ctx, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", - IVAL(guid->info, 0), SVAL(guid->info, 4), - SVAL(guid->info, 6), - guid->info[8], guid->info[9], - guid->info[10], guid->info[11], - guid->info[12], guid->info[13], - guid->info[14], guid->info[15]); + guid->time_low, guid->time_mid, + guid->time_hi_and_version, + guid->clock_seq[0], + guid->clock_seq[1], + guid->node[0], guid->node[1], + guid->node[2], guid->node[3], + guid->node[4], guid->node[5]); } void ndr_print_GUID(struct ndr_print *ndr, const char *name, const struct GUID *guid) -- cgit From 7779b1e00022599f9b77dab7f5f983d930514f15 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 16 Dec 2003 09:20:34 +0000 Subject: added support for big-endian ucs2 strings (as used by big-endian msrpc). this was easier than I expected! (This used to be commit a0a51af6b746b1f82faaa49d33c17fea9d708fb0) --- source4/librpc/ndr/ndr_basic.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index ed75b8c27c..cde0b52f3b 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -344,11 +344,16 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) uint32 len1, ofs, len2; uint16 len3; int ret; + int chset = CH_UCS2; if (!(ndr_flags & NDR_SCALARS)) { return NT_STATUS_OK; } + if (ndr->flags & LIBNDR_FLAG_BIGENDIAN) { + chset = CH_UCS2BE; + } + switch (ndr->flags & LIBNDR_STRING_FLAGS) { case LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4: case LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_NOTERM: @@ -365,7 +370,7 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) break; } NDR_PULL_NEED_BYTES(ndr, len2*2); - ret = convert_string_talloc(ndr->mem_ctx, CH_UCS2, CH_UNIX, + ret = convert_string_talloc(ndr->mem_ctx, chset, CH_UNIX, ndr->data+ndr->offset, len2*2, (const void **)&as); @@ -384,7 +389,7 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) *s = talloc_strdup(ndr->mem_ctx, ""); break; } - ret = convert_string_talloc(ndr->mem_ctx, CH_UCS2, CH_UNIX, + ret = convert_string_talloc(ndr->mem_ctx, chset, CH_UNIX, ndr->data+ndr->offset, len1*2, (const void **)&as); @@ -402,7 +407,7 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) if (len1*2+2 <= ndr->data_size - ndr->offset) { len1++; } - ret = convert_string_talloc(ndr->mem_ctx, CH_UCS2, CH_UNIX, + ret = convert_string_talloc(ndr->mem_ctx, chset, CH_UNIX, ndr->data+ndr->offset, len1*2, (const void **)s); @@ -461,10 +466,15 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) { ssize_t s_len, c_len; int ret; + int chset = CH_UCS2; if (!(ndr_flags & NDR_SCALARS)) { return NT_STATUS_OK; } + + if (ndr->flags & LIBNDR_FLAG_BIGENDIAN) { + chset = CH_UCS2BE; + } s_len = s?strlen(s):0; c_len = s?strlen_m(s):0; @@ -475,7 +485,7 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) NDR_CHECK(ndr_push_uint32(ndr, 0)); NDR_CHECK(ndr_push_uint32(ndr, c_len+1)); NDR_PUSH_NEED_BYTES(ndr, c_len*2 + 2); - ret = convert_string(CH_UNIX, CH_UCS2, + ret = convert_string(CH_UNIX, chset, s, s_len+1, ndr->data+ndr->offset, c_len*2 + 2); if (ret == -1) { @@ -490,7 +500,7 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) NDR_CHECK(ndr_push_uint32(ndr, 0)); NDR_CHECK(ndr_push_uint32(ndr, c_len)); NDR_PUSH_NEED_BYTES(ndr, c_len*2); - ret = convert_string(CH_UNIX, CH_UCS2, + ret = convert_string(CH_UNIX, chset, s, s_len, ndr->data+ndr->offset, c_len*2); if (ret == -1) { @@ -503,7 +513,7 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) case LIBNDR_FLAG_STR_SIZE4: NDR_CHECK(ndr_push_uint32(ndr, c_len + 1)); NDR_PUSH_NEED_BYTES(ndr, c_len*2 + 2); - ret = convert_string(CH_UNIX, CH_UCS2, + ret = convert_string(CH_UNIX, chset, s, s_len + 1, ndr->data+ndr->offset, c_len*2 + 2); if (ret == -1) { @@ -515,7 +525,7 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) case LIBNDR_FLAG_STR_NULLTERM: NDR_PUSH_NEED_BYTES(ndr, c_len*2 + 2); - ret = convert_string(CH_UNIX, CH_UCS2, + ret = convert_string(CH_UNIX, chset, s, s_len+1, ndr->data+ndr->offset, c_len*2 + 2); if (ret == -1) { -- cgit From 60deb10a2c9cd41c6ab3ff5e788858ba203e490f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 16 Dec 2003 12:11:00 +0000 Subject: fixed formatting of uuids in debug output (This used to be commit 7895796ef8a0dfe5de1404e630b2489fdec39a56) --- source4/librpc/ndr/ndr_basic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index cde0b52f3b..be4f16e89b 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -804,7 +804,7 @@ const char *GUID_string(TALLOC_CTX *mem_ctx, const struct GUID *guid) void ndr_print_GUID(struct ndr_print *ndr, const char *name, const struct GUID *guid) { - ndr->print(ndr, "%-25s: %s", GUID_string(ndr->mem_ctx, guid)); + ndr->print(ndr, "%-25s: %s", name, GUID_string(ndr->mem_ctx, guid)); } void ndr_print_DATA_BLOB(struct ndr_print *ndr, const char *name, DATA_BLOB r) -- cgit From 2558f81a8d60435b6618f1c7b408117a765d94ff Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 31 Dec 2003 01:32:33 +0000 Subject: the endpoint mapper now works in bigendian mode (This used to be commit 1f89d89954a3501e08efa97d1276ba9bb2d2305f) --- source4/librpc/ndr/ndr_basic.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index be4f16e89b..0c63faf347 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -22,7 +22,7 @@ #include "includes.h" -#define NDR_BE(ndr) ((ndr)->flags & LIBNDR_FLAG_BIGENDIAN) +#define NDR_BE(ndr) (((ndr)->flags & (LIBNDR_FLAG_BIGENDIAN|LIBNDR_FLAG_LITTLE_ENDIAN)) == LIBNDR_FLAG_BIGENDIAN) #define NDR_SVAL(ndr, ofs) (NDR_BE(ndr)?RSVAL(ndr->data,ofs):SVAL(ndr->data,ofs)) #define NDR_IVAL(ndr, ofs) (NDR_BE(ndr)?RIVAL(ndr->data,ofs):IVAL(ndr->data,ofs)) #define NDR_SSVAL(ndr, ofs, v) do { if (NDR_BE(ndr)) { RSSVAL(ndr->data,ofs,v); } else SSVAL(ndr->data,ofs,v); } while (0) @@ -350,7 +350,7 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) return NT_STATUS_OK; } - if (ndr->flags & LIBNDR_FLAG_BIGENDIAN) { + if (NDR_BE(ndr)) { chset = CH_UCS2BE; } @@ -472,7 +472,7 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) return NT_STATUS_OK; } - if (ndr->flags & LIBNDR_FLAG_BIGENDIAN) { + if (NDR_BE(ndr)) { chset = CH_UCS2BE; } -- cgit From ac193579e7db00c7a2ea0aadaaf0d34c10dcf1a5 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 10 Apr 2004 20:18:22 +0000 Subject: r152: a quick airport commit .... added ldbedit, a _really_ useful command added ldbadd, ldbdel, ldbsearch and ldbmodify to build solved lots of timezone issues, we now pass the torture tests with client and server in different zones fixed several build issues I know this breaks the no-LDAP build. Wait till I arrive in San Jose for that fix. (This used to be commit af34710d4da1841653624fe304b1c8d812c0fdd9) --- source4/librpc/ndr/ndr_basic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 0c63faf347..570f7719a4 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -678,7 +678,7 @@ void ndr_print_time_t(struct ndr_print *ndr, const char *name, time_t t) if (t == (time_t)-1 || t == 0) { ndr->print(ndr, "%-25s: (time_t)%d", name, (int)t); } else { - ndr->print(ndr, "%-25s: %s", name, http_timestring(ndr->mem_ctx, t)); + ndr->print(ndr, "%-25s: %s", name, timestring(ndr->mem_ctx, t)); } } -- cgit From 8fce9e3c549bcf1433119333ddbbf0a3dc4af8d9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 19 Apr 2004 05:48:03 +0000 Subject: r275: added IDL and test code for samr_QueryDisplayInfo3(), samr_AddMultipleMembersToAlias(), samr_RemoveMultipleMembersFromAlias(), samr_OemChangePasswordUser2(), and samr_ChangePasswordUser2() The password change functions don't actually work yet (but should soon). At this stage I have just completed the IDL for them. Next step is to get the hash verifiers right and the torture test should be able to do password changes. (This used to be commit 849d0d314a2add80f2b2be6b503fea05973f998e) --- source4/librpc/ndr/ndr_basic.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 570f7719a4..33176ec9c0 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -419,6 +419,7 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) break; case LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4: + case LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_NOTERM: NDR_CHECK(ndr_pull_uint32(ndr, &len1)); NDR_CHECK(ndr_pull_uint32(ndr, &ofs)); NDR_CHECK(ndr_pull_uint32(ndr, &len2)); @@ -550,6 +551,21 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) ndr->offset += c_len + 1; break; + case LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_NOTERM: + NDR_CHECK(ndr_push_uint32(ndr, c_len)); + NDR_CHECK(ndr_push_uint32(ndr, 0)); + NDR_CHECK(ndr_push_uint32(ndr, c_len)); + NDR_PUSH_NEED_BYTES(ndr, c_len); + ret = convert_string(CH_UNIX, CH_DOS, + s, s_len, + ndr->data+ndr->offset, c_len); + if (ret == -1) { + return ndr_push_error(ndr, NDR_ERR_CHARCNV, + "Bad character conversion"); + } + ndr->offset += c_len; + break; + case LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_LEN4: NDR_CHECK(ndr_push_uint32(ndr, 0)); NDR_CHECK(ndr_push_uint32(ndr, c_len+1)); @@ -733,8 +749,8 @@ void ndr_print_array_uint8(struct ndr_print *ndr, const char *name, { int i; - if (count <= 32 && (ndr->flags & LIBNDR_PRINT_ARRAY_HEX)) { - char s[65]; + if (count <= 600 && (ndr->flags & LIBNDR_PRINT_ARRAY_HEX)) { + char s[1202]; for (i=0;i Date: Tue, 25 May 2004 13:57:39 +0000 Subject: r873: converted samba4 to use real 64 bit integers instead of structures. This was suggested by metze recently. I checked on the build farm and all the machines we have support 64 bit ints, and support the LL suffix for 64 bit constants. I suspect some won't support strtoll() and related functions, so we will probably need replacements for those. (This used to be commit 9a9244a1c66654c12abe4379661cba83a73c4c21) --- source4/librpc/ndr/ndr_basic.c | 77 +++++++++++++++++++++++++++++++++--------- 1 file changed, 61 insertions(+), 16 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 33176ec9c0..f4cdf44dc0 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -66,18 +66,35 @@ NTSTATUS ndr_pull_uint32(struct ndr_pull *ndr, uint32 *v) } /* - parse a HYPER_T + parse a uint64 */ -NTSTATUS ndr_pull_HYPER_T(struct ndr_pull *ndr, HYPER_T *v) +NTSTATUS ndr_pull_uint64(struct ndr_pull *ndr, uint64_t *v) { - NDR_PULL_ALIGN(ndr, 8); + NDR_PULL_ALIGN(ndr, 4); NDR_PULL_NEED_BYTES(ndr, 8); - v->low = NDR_IVAL(ndr, ndr->offset); - v->high = NDR_IVAL(ndr, ndr->offset+4); + *v = NDR_IVAL(ndr, ndr->offset); + *v |= (uint64_t)(NDR_IVAL(ndr, ndr->offset+4)) << 32; ndr->offset += 8; return NT_STATUS_OK; } +/* + parse a int64 +*/ +NTSTATUS ndr_pull_int64(struct ndr_pull *ndr, int64_t *v) +{ + return ndr_pull_uint64(ndr, (uint64_t *)v); +} + +/* + parse a HYPER_T +*/ +NTSTATUS ndr_pull_HYPER_T(struct ndr_pull *ndr, HYPER_T *v) +{ + NDR_PULL_ALIGN(ndr, 8); + return ndr_pull_uint64(ndr, v); +} + /* pull a NTSTATUS */ @@ -215,18 +232,35 @@ NTSTATUS ndr_push_uint32(struct ndr_push *ndr, uint32 v) } /* - push a HYPER_T + push a uint64 */ -NTSTATUS ndr_push_HYPER_T(struct ndr_push *ndr, HYPER_T v) +NTSTATUS ndr_push_uint64(struct ndr_push *ndr, uint64 v) { - NDR_PUSH_ALIGN(ndr, 8); + NDR_PUSH_ALIGN(ndr, 4); NDR_PUSH_NEED_BYTES(ndr, 8); - NDR_SIVAL(ndr, ndr->offset, v.low); - NDR_SIVAL(ndr, ndr->offset+4, v.high); + NDR_SIVAL(ndr, ndr->offset, (v & 0xFFFFFFFF)); + NDR_SIVAL(ndr, ndr->offset+4, (v>>32)); ndr->offset += 8; return NT_STATUS_OK; } +/* + push a int64 +*/ +NTSTATUS ndr_push_int64(struct ndr_push *ndr, int64 v) +{ + return ndr_push_uint64(ndr, (uint64_t)v); +} + +/* + push a HYPER_T +*/ +NTSTATUS ndr_push_HYPER_T(struct ndr_push *ndr, HYPER_T v) +{ + NDR_PUSH_ALIGN(ndr, 8); + return ndr_push_uint64(ndr, v); +} + NTSTATUS ndr_push_align(struct ndr_push *ndr, size_t size) { NDR_PUSH_ALIGN(ndr, size); @@ -606,8 +640,7 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) */ NTSTATUS ndr_push_NTTIME(struct ndr_push *ndr, NTTIME t) { - NDR_CHECK(ndr_push_uint32(ndr, t.low)); - NDR_CHECK(ndr_push_uint32(ndr, t.high)); + NDR_CHECK(ndr_push_uint64(ndr, t)); return NT_STATUS_OK; } @@ -616,8 +649,7 @@ NTSTATUS ndr_push_NTTIME(struct ndr_push *ndr, NTTIME t) */ NTSTATUS ndr_pull_NTTIME(struct ndr_pull *ndr, NTTIME *t) { - NDR_CHECK(ndr_pull_uint32(ndr, &t->low)); - NDR_CHECK(ndr_pull_uint32(ndr, &t->high)); + NDR_CHECK(ndr_pull_uint64(ndr, t)); return NT_STATUS_OK; } @@ -661,9 +693,22 @@ void ndr_print_uint32(struct ndr_print *ndr, const char *name, uint32 v) ndr->print(ndr, "%-25s: 0x%08x (%u)", name, v, v); } +void ndr_print_uint64(struct ndr_print *ndr, const char *name, uint64 v) +{ + ndr->print(ndr, "%-25s: 0x%08x%08x", name, (uint32)(v >> 32), (uint32)(v & 0xFFFFFFFF)); +} + +void ndr_print_int64(struct ndr_print *ndr, const char *name, int64 v) +{ + ndr->print(ndr, "%-25s: 0x%08x%08x (%lld)", name, + (uint32)(v >> 32), + (uint32)(v & 0xFFFFFFFF), + v); +} + void ndr_print_HYPER_T(struct ndr_print *ndr, const char *name, HYPER_T v) { - ndr->print(ndr, "%-25s: 0x%08x%08x", name, v.high, v.low); + ndr->print(ndr, "%-25s: 0x%08x%08x", name, (uint32)(v >> 32), (uint32)(v & 0xFFFFFFFF)); } void ndr_print_ptr(struct ndr_print *ndr, const char *name, const void *p) @@ -686,7 +731,7 @@ void ndr_print_string(struct ndr_print *ndr, const char *name, const char *s) void ndr_print_NTTIME(struct ndr_print *ndr, const char *name, NTTIME t) { - ndr->print(ndr, "%-25s: %s", name, nt_time_string(ndr->mem_ctx, &t)); + ndr->print(ndr, "%-25s: %s", name, nt_time_string(ndr->mem_ctx, t)); } void ndr_print_time_t(struct ndr_print *ndr, const char *name, time_t t) -- cgit From f9d8f8843dc0ab8c9d59abde7222e0f118b86b5d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 25 May 2004 16:24:13 +0000 Subject: r884: convert samba4 to use [u]int32_t instead of [u]int32 metze (This used to be commit 0e5517d937a2eb7cf707991d1c7498c1ab456095) --- source4/librpc/ndr/ndr_basic.c | 70 +++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 35 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index f4cdf44dc0..5b20f118f7 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -54,9 +54,9 @@ NTSTATUS ndr_pull_uint16(struct ndr_pull *ndr, uint16 *v) /* - parse a uint32 + parse a uint32_t */ -NTSTATUS ndr_pull_uint32(struct ndr_pull *ndr, uint32 *v) +NTSTATUS ndr_pull_uint32(struct ndr_pull *ndr, uint32_t *v) { NDR_PULL_ALIGN(ndr, 4); NDR_PULL_NEED_BYTES(ndr, 4); @@ -100,7 +100,7 @@ NTSTATUS ndr_pull_HYPER_T(struct ndr_pull *ndr, HYPER_T *v) */ NTSTATUS ndr_pull_NTSTATUS(struct ndr_pull *ndr, NTSTATUS *status) { - uint32 v; + uint32_t v; NDR_CHECK(ndr_pull_uint32(ndr, &v)); *status = NT_STATUS(v); return NT_STATUS_OK; @@ -124,7 +124,7 @@ void ndr_print_NTSTATUS(struct ndr_print *ndr, const char *name, NTSTATUS *r) */ NTSTATUS ndr_pull_WERROR(struct ndr_pull *ndr, WERROR *status) { - uint32 v; + uint32_t v; NDR_CHECK(ndr_pull_uint32(ndr, &v)); *status = W_ERROR(v); return NT_STATUS_OK; @@ -146,7 +146,7 @@ void ndr_print_WERROR(struct ndr_print *ndr, const char *name, WERROR *r) /* parse a set of bytes */ -NTSTATUS ndr_pull_bytes(struct ndr_pull *ndr, char *data, uint32 n) +NTSTATUS ndr_pull_bytes(struct ndr_pull *ndr, char *data, uint32_t n) { NDR_PULL_NEED_BYTES(ndr, n); memcpy(data, ndr->data + ndr->offset, n); @@ -157,7 +157,7 @@ NTSTATUS ndr_pull_bytes(struct ndr_pull *ndr, char *data, uint32 n) /* pull an array of uint8 */ -NTSTATUS ndr_pull_array_uint8(struct ndr_pull *ndr, int ndr_flags, char *data, uint32 n) +NTSTATUS ndr_pull_array_uint8(struct ndr_pull *ndr, int ndr_flags, char *data, uint32_t n) { if (!(ndr_flags & NDR_SCALARS)) { return NT_STATUS_OK; @@ -169,9 +169,9 @@ NTSTATUS ndr_pull_array_uint8(struct ndr_pull *ndr, int ndr_flags, char *data, u /* pull an array of uint16 */ -NTSTATUS ndr_pull_array_uint16(struct ndr_pull *ndr, int ndr_flags, uint16 *data, uint32 n) +NTSTATUS ndr_pull_array_uint16(struct ndr_pull *ndr, int ndr_flags, uint16 *data, uint32_t n) { - uint32 i; + uint32_t i; if (!(ndr_flags & NDR_SCALARS)) { return NT_STATUS_OK; } @@ -182,11 +182,11 @@ NTSTATUS ndr_pull_array_uint16(struct ndr_pull *ndr, int ndr_flags, uint16 *data } /* - pull a const array of uint32 + pull a const array of uint32_t */ -NTSTATUS ndr_pull_array_uint32(struct ndr_pull *ndr, int ndr_flags, uint32 *data, uint32 n) +NTSTATUS ndr_pull_array_uint32(struct ndr_pull *ndr, int ndr_flags, uint32_t *data, uint32_t n) { - uint32 i; + uint32_t i; if (!(ndr_flags & NDR_SCALARS)) { return NT_STATUS_OK; } @@ -220,9 +220,9 @@ NTSTATUS ndr_push_uint16(struct ndr_push *ndr, uint16 v) } /* - push a uint32 + push a uint32_t */ -NTSTATUS ndr_push_uint32(struct ndr_push *ndr, uint32 v) +NTSTATUS ndr_push_uint32(struct ndr_push *ndr, uint32_t v) { NDR_PUSH_ALIGN(ndr, 4); NDR_PUSH_NEED_BYTES(ndr, 4); @@ -276,7 +276,7 @@ NTSTATUS ndr_pull_align(struct ndr_pull *ndr, size_t size) /* push some bytes */ -NTSTATUS ndr_push_bytes(struct ndr_push *ndr, const char *data, uint32 n) +NTSTATUS ndr_push_bytes(struct ndr_push *ndr, const char *data, uint32_t n) { NDR_PUSH_NEED_BYTES(ndr, n); memcpy(ndr->data + ndr->offset, data, n); @@ -287,7 +287,7 @@ NTSTATUS ndr_push_bytes(struct ndr_push *ndr, const char *data, uint32 n) /* push some zero bytes */ -NTSTATUS ndr_push_zero(struct ndr_push *ndr, uint32 n) +NTSTATUS ndr_push_zero(struct ndr_push *ndr, uint32_t n) { NDR_PUSH_NEED_BYTES(ndr, n); memset(ndr->data + ndr->offset, 0, n); @@ -298,7 +298,7 @@ NTSTATUS ndr_push_zero(struct ndr_push *ndr, uint32 n) /* push an array of uint8 */ -NTSTATUS ndr_push_array_uint8(struct ndr_push *ndr, int ndr_flags, const char *data, uint32 n) +NTSTATUS ndr_push_array_uint8(struct ndr_push *ndr, int ndr_flags, const char *data, uint32_t n) { if (!(ndr_flags & NDR_SCALARS)) { return NT_STATUS_OK; @@ -309,7 +309,7 @@ NTSTATUS ndr_push_array_uint8(struct ndr_push *ndr, int ndr_flags, const char *d /* push an array of uint16 */ -NTSTATUS ndr_push_array_uint16(struct ndr_push *ndr, int ndr_flags, const uint16 *data, uint32 n) +NTSTATUS ndr_push_array_uint16(struct ndr_push *ndr, int ndr_flags, const uint16 *data, uint32_t n) { int i; if (!(ndr_flags & NDR_SCALARS)) { @@ -322,9 +322,9 @@ NTSTATUS ndr_push_array_uint16(struct ndr_push *ndr, int ndr_flags, const uint16 } /* - push an array of uint32 + push an array of uint32_t */ -NTSTATUS ndr_push_array_uint32(struct ndr_push *ndr, int ndr_flags, const uint32 *data, uint32 n) +NTSTATUS ndr_push_array_uint32(struct ndr_push *ndr, int ndr_flags, const uint32_t *data, uint32_t n) { int i; if (!(ndr_flags & NDR_SCALARS)) { @@ -357,7 +357,7 @@ void ndr_push_restore(struct ndr_push *ndr, struct ndr_push_save *save) */ NTSTATUS ndr_push_ptr(struct ndr_push *ndr, const void *p) { - uint32 ptr = 0; + uint32_t ptr = 0; if (p) { /* we do this to ensure that we generate unique ref ids, which means we can handle the case where a MS programmer @@ -375,7 +375,7 @@ NTSTATUS ndr_push_ptr(struct ndr_push *ndr, const void *p) NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) { char *as=NULL; - uint32 len1, ofs, len2; + uint32_t len1, ofs, len2; uint16 len3; int ret; int chset = CH_UCS2; @@ -666,7 +666,7 @@ NTSTATUS ndr_push_time_t(struct ndr_push *ndr, time_t t) */ NTSTATUS ndr_pull_time_t(struct ndr_pull *ndr, time_t *t) { - uint32 tt; + uint32_t tt; NDR_CHECK(ndr_pull_uint32(ndr, &tt)); *t = tt; return NT_STATUS_OK; @@ -688,27 +688,27 @@ void ndr_print_uint16(struct ndr_print *ndr, const char *name, uint16 v) ndr->print(ndr, "%-25s: 0x%04x (%u)", name, v, v); } -void ndr_print_uint32(struct ndr_print *ndr, const char *name, uint32 v) +void ndr_print_uint32(struct ndr_print *ndr, const char *name, uint32_t v) { ndr->print(ndr, "%-25s: 0x%08x (%u)", name, v, v); } void ndr_print_uint64(struct ndr_print *ndr, const char *name, uint64 v) { - ndr->print(ndr, "%-25s: 0x%08x%08x", name, (uint32)(v >> 32), (uint32)(v & 0xFFFFFFFF)); + ndr->print(ndr, "%-25s: 0x%08x%08x", name, (uint32_t)(v >> 32), (uint32_t)(v & 0xFFFFFFFF)); } void ndr_print_int64(struct ndr_print *ndr, const char *name, int64 v) { ndr->print(ndr, "%-25s: 0x%08x%08x (%lld)", name, - (uint32)(v >> 32), - (uint32)(v & 0xFFFFFFFF), + (uint32_t)(v >> 32), + (uint32_t)(v & 0xFFFFFFFF), v); } void ndr_print_HYPER_T(struct ndr_print *ndr, const char *name, HYPER_T v) { - ndr->print(ndr, "%-25s: 0x%08x%08x", name, (uint32)(v >> 32), (uint32)(v & 0xFFFFFFFF)); + ndr->print(ndr, "%-25s: 0x%08x%08x", name, (uint32_t)(v >> 32), (uint32_t)(v & 0xFFFFFFFF)); } void ndr_print_ptr(struct ndr_print *ndr, const char *name, const void *p) @@ -754,7 +754,7 @@ void ndr_print_bad_level(struct ndr_print *ndr, const char *name, uint16 level) } void ndr_print_array_uint32(struct ndr_print *ndr, const char *name, - const uint32 *data, uint32 count) + const uint32_t *data, uint32_t count) { int i; @@ -772,7 +772,7 @@ void ndr_print_array_uint32(struct ndr_print *ndr, const char *name, } void ndr_print_array_uint16(struct ndr_print *ndr, const char *name, - const uint16 *data, uint32 count) + const uint16 *data, uint32_t count) { int i; @@ -790,7 +790,7 @@ void ndr_print_array_uint16(struct ndr_print *ndr, const char *name, } void ndr_print_array_uint8(struct ndr_print *ndr, const char *name, - const uint8 *data, uint32 count) + const uint8 *data, uint32_t count) { int i; @@ -822,10 +822,10 @@ void ndr_print_array_uint8(struct ndr_print *ndr, const char *name, */ NTSTATUS GUID_from_string(const char *s, struct GUID *guid) { - uint32 time_low; - uint32 time_mid, time_hi_and_version; - uint32 clock_seq[2]; - uint32 node[6]; + uint32_t time_low; + uint32_t time_mid, time_hi_and_version; + uint32_t clock_seq[2]; + uint32_t node[6]; int i; if (11 != sscanf(s, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", @@ -904,7 +904,7 @@ NTSTATUS ndr_push_DATA_BLOB(struct ndr_push *ndr, DATA_BLOB blob) */ NTSTATUS ndr_pull_DATA_BLOB(struct ndr_pull *ndr, DATA_BLOB *blob) { - uint32 length; + uint32_t length; if (ndr->flags & LIBNDR_ALIGN_FLAGS) { if (ndr->flags & LIBNDR_FLAG_ALIGN2) { -- cgit From f88bf54c7f6d1c2ef833047eb8327953c304b5ff Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 25 May 2004 17:24:24 +0000 Subject: r889: convert samba4 to use [u]int16_t instead of [u]int16 metze (This used to be commit af6f1f8a01bebbecd99bc8c066519e89966e65e3) --- source4/librpc/ndr/ndr_basic.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 5b20f118f7..9bfb312c3a 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -43,7 +43,7 @@ NTSTATUS ndr_pull_uint8(struct ndr_pull *ndr, uint8 *v) /* parse a uint16 */ -NTSTATUS ndr_pull_uint16(struct ndr_pull *ndr, uint16 *v) +NTSTATUS ndr_pull_uint16(struct ndr_pull *ndr, uint16_t *v) { NDR_PULL_ALIGN(ndr, 2); NDR_PULL_NEED_BYTES(ndr, 2); @@ -169,7 +169,7 @@ NTSTATUS ndr_pull_array_uint8(struct ndr_pull *ndr, int ndr_flags, char *data, u /* pull an array of uint16 */ -NTSTATUS ndr_pull_array_uint16(struct ndr_pull *ndr, int ndr_flags, uint16 *data, uint32_t n) +NTSTATUS ndr_pull_array_uint16(struct ndr_pull *ndr, int ndr_flags, uint16_t *data, uint32_t n) { uint32_t i; if (!(ndr_flags & NDR_SCALARS)) { @@ -210,7 +210,7 @@ NTSTATUS ndr_push_uint8(struct ndr_push *ndr, uint8 v) /* push a uint16 */ -NTSTATUS ndr_push_uint16(struct ndr_push *ndr, uint16 v) +NTSTATUS ndr_push_uint16(struct ndr_push *ndr, uint16_t v) { NDR_PUSH_ALIGN(ndr, 2); NDR_PUSH_NEED_BYTES(ndr, 2); @@ -309,7 +309,7 @@ NTSTATUS ndr_push_array_uint8(struct ndr_push *ndr, int ndr_flags, const char *d /* push an array of uint16 */ -NTSTATUS ndr_push_array_uint16(struct ndr_push *ndr, int ndr_flags, const uint16 *data, uint32_t n) +NTSTATUS ndr_push_array_uint16(struct ndr_push *ndr, int ndr_flags, const uint16_t *data, uint32_t n) { int i; if (!(ndr_flags & NDR_SCALARS)) { @@ -376,7 +376,7 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) { char *as=NULL; uint32_t len1, ofs, len2; - uint16 len3; + uint16_t len3; int ret; int chset = CH_UCS2; @@ -683,7 +683,7 @@ void ndr_print_uint8(struct ndr_print *ndr, const char *name, uint8 v) ndr->print(ndr, "%-25s: 0x%02x (%u)", name, v, v); } -void ndr_print_uint16(struct ndr_print *ndr, const char *name, uint16 v) +void ndr_print_uint16(struct ndr_print *ndr, const char *name, uint16_t v) { ndr->print(ndr, "%-25s: 0x%04x (%u)", name, v, v); } @@ -743,12 +743,12 @@ void ndr_print_time_t(struct ndr_print *ndr, const char *name, time_t t) } } -void ndr_print_union(struct ndr_print *ndr, const char *name, uint16 level, const char *type) +void ndr_print_union(struct ndr_print *ndr, const char *name, uint16_t level, const char *type) { ndr->print(ndr, "%-25s: union %s(case %u)", name, type, level); } -void ndr_print_bad_level(struct ndr_print *ndr, const char *name, uint16 level) +void ndr_print_bad_level(struct ndr_print *ndr, const char *name, uint16_t level) { ndr->print(ndr, "UNKNOWN LEVEL %u", level); } @@ -772,7 +772,7 @@ void ndr_print_array_uint32(struct ndr_print *ndr, const char *name, } void ndr_print_array_uint16(struct ndr_print *ndr, const char *name, - const uint16 *data, uint32_t count) + const uint16_t *data, uint32_t count) { int i; -- cgit From fcd718c7d8a6850ae8719f23ed044b06b57501cd Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 25 May 2004 17:50:17 +0000 Subject: r890: convert samba4 to use [u]int8_t instead of [u]int8 metze (This used to be commit 2986c5f08c8f0c26a2ea7b6ce20aae025183109f) --- source4/librpc/ndr/ndr_basic.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 9bfb312c3a..687e457129 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -31,7 +31,7 @@ /* parse a uint8 */ -NTSTATUS ndr_pull_uint8(struct ndr_pull *ndr, uint8 *v) +NTSTATUS ndr_pull_uint8(struct ndr_pull *ndr, uint8_t *v) { NDR_PULL_NEED_BYTES(ndr, 1); *v = CVAL(ndr->data, ndr->offset); @@ -199,7 +199,7 @@ NTSTATUS ndr_pull_array_uint32(struct ndr_pull *ndr, int ndr_flags, uint32_t *da /* push a uint8 */ -NTSTATUS ndr_push_uint8(struct ndr_push *ndr, uint8 v) +NTSTATUS ndr_push_uint8(struct ndr_push *ndr, uint8_t v) { NDR_PUSH_NEED_BYTES(ndr, 1); SCVAL(ndr->data, ndr->offset, v); @@ -678,7 +678,7 @@ void ndr_print_struct(struct ndr_print *ndr, const char *name, const char *type) ndr->print(ndr, "%s: struct %s", name, type); } -void ndr_print_uint8(struct ndr_print *ndr, const char *name, uint8 v) +void ndr_print_uint8(struct ndr_print *ndr, const char *name, uint8_t v) { ndr->print(ndr, "%-25s: 0x%02x (%u)", name, v, v); } @@ -790,7 +790,7 @@ void ndr_print_array_uint16(struct ndr_print *ndr, const char *name, } void ndr_print_array_uint8(struct ndr_print *ndr, const char *name, - const uint8 *data, uint32_t count) + const uint8_t *data, uint32_t count) { int i; -- cgit From 17b5630bf7a04ffb90e422add5fa19dc16fca9d2 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 26 May 2004 01:14:56 +0000 Subject: r895: use _t in base ndr fns (This used to be commit b3c00acdf0e85563b5d5ce1f9bc86cc2e781d53e) --- source4/librpc/ndr/ndr_basic.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 687e457129..1766d47e14 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -234,7 +234,7 @@ NTSTATUS ndr_push_uint32(struct ndr_push *ndr, uint32_t v) /* push a uint64 */ -NTSTATUS ndr_push_uint64(struct ndr_push *ndr, uint64 v) +NTSTATUS ndr_push_uint64(struct ndr_push *ndr, uint64_t v) { NDR_PUSH_ALIGN(ndr, 4); NDR_PUSH_NEED_BYTES(ndr, 8); @@ -247,7 +247,7 @@ NTSTATUS ndr_push_uint64(struct ndr_push *ndr, uint64 v) /* push a int64 */ -NTSTATUS ndr_push_int64(struct ndr_push *ndr, int64 v) +NTSTATUS ndr_push_int64(struct ndr_push *ndr, int64_t v) { return ndr_push_uint64(ndr, (uint64_t)v); } @@ -693,12 +693,12 @@ void ndr_print_uint32(struct ndr_print *ndr, const char *name, uint32_t v) ndr->print(ndr, "%-25s: 0x%08x (%u)", name, v, v); } -void ndr_print_uint64(struct ndr_print *ndr, const char *name, uint64 v) +void ndr_print_uint64(struct ndr_print *ndr, const char *name, uint64_t v) { ndr->print(ndr, "%-25s: 0x%08x%08x", name, (uint32_t)(v >> 32), (uint32_t)(v & 0xFFFFFFFF)); } -void ndr_print_int64(struct ndr_print *ndr, const char *name, int64 v) +void ndr_print_int64(struct ndr_print *ndr, const char *name, int64_t v) { ndr->print(ndr, "%-25s: 0x%08x%08x (%lld)", name, (uint32_t)(v >> 32), -- cgit From d9538e7412c593a9dc10a600676939d2cf0205ea Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 28 May 2004 13:23:30 +0000 Subject: r937: - added a simple QuerySecurity implementation in samr server - moved some sec desc defines into misc.idl - fixed pw_len field in UserInfo26 - made some pipes available on TCP - added netr_DsrEnumerateDomainTrusts() to netlogon - added templates for remaining netlogon IDL calls (from ethereal) - added a unistr_noterm vs unistr error detector in ndr basic decoder - added torture test for netr_DsrEnumerateDomainTrusts() (This used to be commit ae5a5113fb83640dcb9ae4642c1b9eaf28487956) --- source4/librpc/ndr/ndr_basic.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 1766d47e14..f8315b3af0 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -413,6 +413,18 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) "Bad character conversion"); } NDR_CHECK(ndr_pull_advance(ndr, len2*2)); + + /* this is a way of detecting if a string is sent with the wrong + termination */ + if (ndr->flags & LIBNDR_FLAG_STR_NOTERM) { + if (strlen(as) < len2) { + DEBUG(6,("short string '%s'\n", as)); + } + } else { + if (strlen(as) == len2) { + DEBUG(6,("long string '%s'\n", as)); + } + } *s = as; break; -- cgit From 5341ad20e1b8953c9256cd8e04a7e55ba9ef84b5 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 5 Jun 2004 05:01:38 +0000 Subject: r1030: added server side schannel support (This used to be commit 2ac79dfba0e64056a680f21d7dd0c007f79d4a70) --- source4/librpc/ndr/ndr_basic.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index f8315b3af0..ea58a77c47 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -497,6 +497,17 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) (*s) = as; break; + case LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM: + len1 = strnlen(ndr->data+ndr->offset, (ndr->data_size - ndr->offset)); + if (len1+1 <= ndr->data_size - ndr->offset) { + len1++; + } + NDR_ALLOC_N(ndr, as, (len1+1)); + NDR_CHECK(ndr_pull_bytes(ndr, as, len1)); + as[len1] = 0; + (*s) = as; + break; + default: return ndr_pull_error(ndr, NDR_ERR_STRING, "Bad string flags 0x%x\n", ndr->flags & LIBNDR_STRING_FLAGS); @@ -639,6 +650,18 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) ndr->offset += c_len + 1; break; + case LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM: + NDR_PUSH_NEED_BYTES(ndr, c_len + 1); + ret = convert_string(CH_UNIX, CH_DOS, + s, s_len+1, + ndr->data+ndr->offset, c_len + 1); + if (ret == -1) { + return ndr_push_error(ndr, NDR_ERR_CHARCNV, + "Bad character conversion"); + } + ndr->offset += c_len + 1; + break; + default: return ndr_push_error(ndr, NDR_ERR_STRING, "Bad string flags 0x%x\n", ndr->flags & LIBNDR_STRING_FLAGS); -- cgit From 004a9979a974775b6c94eabf5c9e7674d31a150a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 14 Jun 2004 07:27:22 +0000 Subject: r1133: - add ndr_pull_ptr() as a separate call instead of ndr_pull_uint32() (useful for debugging IDL) - fixed a couple of places that auto-generate incorrect printf style arguments for ndr_pull_error() (This used to be commit ad3324a79ce030df4c5ed46408e662b46588f89f) --- source4/librpc/ndr/ndr_basic.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index ea58a77c47..5d4ade096f 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -65,6 +65,16 @@ NTSTATUS ndr_pull_uint32(struct ndr_pull *ndr, uint32_t *v) return NT_STATUS_OK; } +/* + parse a pointer +*/ +NTSTATUS ndr_pull_ptr(struct ndr_pull *ndr, uint32_t *v) +{ + NTSTATUS status; + status = ndr_pull_uint32(ndr, v); + return status; +} + /* parse a uint64 */ -- cgit From 81db9ef4425ed0d3397767f722b9f156b334867c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 24 Jun 2004 17:07:19 +0000 Subject: r1239: move the old msrpc_() functions to ndr__format_blob() simular to ndr__struct_blob() metze (This used to be commit b25dd341e0febd550a2936ca484b6fecce2ff8c2) --- source4/librpc/ndr/ndr_basic.c | 301 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 301 insertions(+) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 5d4ade096f..1adf6ea1d3 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -972,3 +972,304 @@ NTSTATUS ndr_pull_DATA_BLOB(struct ndr_pull *ndr, DATA_BLOB *blob) ndr->offset += length; return NT_STATUS_OK; } + +/* + this is a tiny ndr packet generator. This + generator is not general enough for all our rpc needs, its just + enough for the ntlmssp code + + format specifiers are: + + U = unicode string (input is unix string) + a = address (input is char *unix_string) + (1 byte type, 1 byte length, unicode/ASCII string, all inline) + A = ASCII string (input is unix string) + B = data blob (pointer + length) + b = data blob in header (pointer + length) + D + d = word (4 bytes) + C = constant ascii string + */ +NTSTATUS ndr_push_format_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, + const char *format, ...) +{ + int i, n; + va_list ap; + char *s; + uint8_t *b; + int head_size=0, data_size=0; + int head_ofs, data_ofs; + + /* first scan the format to work out the header and body size */ + va_start(ap, format); + for (i=0; format[i]; i++) { + switch (format[i]) { + case 'U': + s = va_arg(ap, char *); + head_size += 8; + data_size += str_charnum(s) * 2; + break; + case 'A': + s = va_arg(ap, char *); + head_size += 8; + data_size += str_ascii_charnum(s); + break; + case 'a': + n = va_arg(ap, int); + s = va_arg(ap, char *); + data_size += (str_charnum(s) * 2) + 4; + break; + case 'B': + b = va_arg(ap, uint8_t *); + head_size += 8; + data_size += va_arg(ap, int); + break; + case 'b': + b = va_arg(ap, uint8_t *); + head_size += va_arg(ap, int); + break; + case 'd': + n = va_arg(ap, int); + head_size += 4; + break; + case 'C': + s = va_arg(ap, char *); + head_size += str_charnum(s) + 1; + break; + } + } + va_end(ap); + + /* allocate the space, then scan the format again to fill in the values */ + *blob = data_blob_talloc(mem_ctx, NULL, head_size + data_size); + + if (blob->length != (head_size + data_size)) { + return NT_STATUS_NO_MEMORY; + } + + head_ofs = 0; + data_ofs = head_size; + + va_start(ap, format); + for (i=0; format[i]; i++) { + switch (format[i]) { + case 'U': + s = va_arg(ap, char *); + n = str_charnum(s); + SSVAL(blob->data, head_ofs, n*2); head_ofs += 2; + SSVAL(blob->data, head_ofs, n*2); head_ofs += 2; + SIVAL(blob->data, head_ofs, data_ofs); head_ofs += 4; + push_string(NULL, blob->data+data_ofs, s, n*2, STR_UNICODE|STR_NOALIGN); + data_ofs += n*2; + break; + case 'A': + s = va_arg(ap, char *); + n = str_ascii_charnum(s); + SSVAL(blob->data, head_ofs, n); head_ofs += 2; + SSVAL(blob->data, head_ofs, n); head_ofs += 2; + SIVAL(blob->data, head_ofs, data_ofs); head_ofs += 4; + push_string(NULL, blob->data+data_ofs, s, n, STR_ASCII|STR_NOALIGN); + data_ofs += n; + break; + case 'a': + n = va_arg(ap, int); + SSVAL(blob->data, data_ofs, n); data_ofs += 2; + s = va_arg(ap, char *); + n = str_charnum(s); + SSVAL(blob->data, data_ofs, n*2); data_ofs += 2; + if (0 < n) { + push_string(NULL, blob->data+data_ofs, s, n*2, + STR_UNICODE|STR_NOALIGN); + } + data_ofs += n*2; + break; + + case 'B': + b = va_arg(ap, uint8_t *); + n = va_arg(ap, int); + SSVAL(blob->data, head_ofs, n); head_ofs += 2; + SSVAL(blob->data, head_ofs, n); head_ofs += 2; + SIVAL(blob->data, head_ofs, data_ofs); head_ofs += 4; + if (n && b) /* don't follow null pointers... */ + memcpy(blob->data+data_ofs, b, n); + data_ofs += n; + break; + case 'd': + n = va_arg(ap, int); + SIVAL(blob->data, head_ofs, n); head_ofs += 4; + break; + case 'b': + b = va_arg(ap, uint8_t *); + n = va_arg(ap, int); + memcpy(blob->data + head_ofs, b, n); + head_ofs += n; + break; + case 'C': + s = va_arg(ap, char *); + head_ofs += push_string(NULL, blob->data+head_ofs, s, -1, + STR_ASCII|STR_TERMINATE); + break; + } + } + va_end(ap); + + return NT_STATUS_OK; +} + + +/* a helpful macro to avoid running over the end of our blob */ +#define NEED_DATA(amount) \ +if ((head_ofs + amount) > blob->length) { \ + return NT_STATUS_INVALID_PARAMETER; \ +} + +/* + this is a tiny msrpc packet parser. This the the partner of msrpc_gen + + format specifiers are: + + U = unicode string (output is unix string) + A = ascii string + B = data blob + b = data blob in header + d = word (4 bytes) + C = constant ascii string + */ + +NTSTATUS ndr_pull_format_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, + const char *format, ...) +{ + int i; + va_list ap; + const char **ps, *s; + DATA_BLOB *b; + size_t head_ofs = 0; + uint16_t len1, len2; + uint32_t ptr; + uint32_t *v; + pstring p; + + va_start(ap, format); + for (i=0; format[i]; i++) { + switch (format[i]) { + case 'U': + NEED_DATA(8); + len1 = SVAL(blob->data, head_ofs); head_ofs += 2; + len2 = SVAL(blob->data, head_ofs); head_ofs += 2; + ptr = IVAL(blob->data, head_ofs); head_ofs += 4; + + ps = va_arg(ap, char **); + if (len1 == 0 && len2 == 0) { + *ps = ""; + } else { + /* make sure its in the right format - be strict */ + if ((len1 != len2) || (ptr + len1 < ptr) || (ptr + len1 < len1) || (ptr + len1 > blob->length)) { + return NT_STATUS_INVALID_PARAMETER; + } + if (len1 & 1) { + /* if odd length and unicode */ + return NT_STATUS_INVALID_PARAMETER; + } + if (blob->data + ptr < (uint8_t *)ptr || blob->data + ptr < blob->data) + return NT_STATUS_INVALID_PARAMETER; + + if (0 < len1) { + pull_string(NULL, p, blob->data + ptr, sizeof(p), + len1, + STR_UNICODE|STR_NOALIGN); + (*ps) = talloc_strdup(mem_ctx, p); + if (!(*ps)) { + return NT_STATUS_NO_MEMORY; + } + } else { + (*ps) = ""; + } + } + break; + case 'A': + NEED_DATA(8); + len1 = SVAL(blob->data, head_ofs); head_ofs += 2; + len2 = SVAL(blob->data, head_ofs); head_ofs += 2; + ptr = IVAL(blob->data, head_ofs); head_ofs += 4; + + ps = va_arg(ap, char **); + /* make sure its in the right format - be strict */ + if (len1 == 0 && len2 == 0) { + *ps = ""; + } else { + if ((len1 != len2) || (ptr + len1 < ptr) || (ptr + len1 < len1) || (ptr + len1 > blob->length)) { + return NT_STATUS_INVALID_PARAMETER; + } + + if (blob->data + ptr < (uint8_t *)ptr || blob->data + ptr < blob->data) + return NT_STATUS_INVALID_PARAMETER; + + if (0 < len1) { + pull_string(NULL, p, blob->data + ptr, sizeof(p), + len1, + STR_ASCII|STR_NOALIGN); + (*ps) = talloc_strdup(mem_ctx, p); + if (!(*ps)) { + return NT_STATUS_NO_MEMORY; + } + } else { + (*ps) = ""; + } + } + break; + case 'B': + NEED_DATA(8); + len1 = SVAL(blob->data, head_ofs); head_ofs += 2; + len2 = SVAL(blob->data, head_ofs); head_ofs += 2; + ptr = IVAL(blob->data, head_ofs); head_ofs += 4; + + b = (DATA_BLOB *)va_arg(ap, void *); + if (len1 == 0 && len2 == 0) { + *b = data_blob_talloc(mem_ctx, NULL, 0); + } else { + /* make sure its in the right format - be strict */ + if ((len1 != len2) || (ptr + len1 < ptr) || (ptr + len1 < len1) || (ptr + len1 > blob->length)) { + return NT_STATUS_INVALID_PARAMETER; + } + + if (blob->data + ptr < (uint8_t *)ptr || blob->data + ptr < blob->data) + return NT_STATUS_INVALID_PARAMETER; + + *b = data_blob_talloc(mem_ctx, blob->data + ptr, len1); + } + break; + case 'b': + b = (DATA_BLOB *)va_arg(ap, void *); + len1 = va_arg(ap, uint_t); + /* make sure its in the right format - be strict */ + NEED_DATA(len1); + if (blob->data + head_ofs < (uint8_t *)head_ofs || blob->data + head_ofs < blob->data) + return NT_STATUS_INVALID_PARAMETER; + + *b = data_blob_talloc(mem_ctx, blob->data + head_ofs, len1); + head_ofs += len1; + break; + case 'd': + v = va_arg(ap, uint32_t *); + NEED_DATA(4); + *v = IVAL(blob->data, head_ofs); head_ofs += 4; + break; + case 'C': + s = va_arg(ap, char *); + + if (blob->data + head_ofs < (uint8_t *)head_ofs || blob->data + head_ofs < blob->data) + return NT_STATUS_INVALID_PARAMETER; + + head_ofs += pull_string(NULL, p, blob->data+head_ofs, sizeof(p), + blob->length - head_ofs, + STR_ASCII|STR_TERMINATE); + if (strcmp(s, p) != 0) { + return NT_STATUS_INVALID_PARAMETER; + } + break; + } + } + va_end(ap); + + return NT_STATUS_OK; +} -- cgit From 25bf685da5c037d1875f96e7e7127106dee2865d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 28 Jun 2004 06:46:27 +0000 Subject: r1274: revert -r 1239 as discussed with abartlet metze (This used to be commit 52e2d038252bd745d53c687d266ad3ad62efa6fc) --- source4/librpc/ndr/ndr_basic.c | 301 ----------------------------------------- 1 file changed, 301 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 1adf6ea1d3..5d4ade096f 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -972,304 +972,3 @@ NTSTATUS ndr_pull_DATA_BLOB(struct ndr_pull *ndr, DATA_BLOB *blob) ndr->offset += length; return NT_STATUS_OK; } - -/* - this is a tiny ndr packet generator. This - generator is not general enough for all our rpc needs, its just - enough for the ntlmssp code - - format specifiers are: - - U = unicode string (input is unix string) - a = address (input is char *unix_string) - (1 byte type, 1 byte length, unicode/ASCII string, all inline) - A = ASCII string (input is unix string) - B = data blob (pointer + length) - b = data blob in header (pointer + length) - D - d = word (4 bytes) - C = constant ascii string - */ -NTSTATUS ndr_push_format_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, - const char *format, ...) -{ - int i, n; - va_list ap; - char *s; - uint8_t *b; - int head_size=0, data_size=0; - int head_ofs, data_ofs; - - /* first scan the format to work out the header and body size */ - va_start(ap, format); - for (i=0; format[i]; i++) { - switch (format[i]) { - case 'U': - s = va_arg(ap, char *); - head_size += 8; - data_size += str_charnum(s) * 2; - break; - case 'A': - s = va_arg(ap, char *); - head_size += 8; - data_size += str_ascii_charnum(s); - break; - case 'a': - n = va_arg(ap, int); - s = va_arg(ap, char *); - data_size += (str_charnum(s) * 2) + 4; - break; - case 'B': - b = va_arg(ap, uint8_t *); - head_size += 8; - data_size += va_arg(ap, int); - break; - case 'b': - b = va_arg(ap, uint8_t *); - head_size += va_arg(ap, int); - break; - case 'd': - n = va_arg(ap, int); - head_size += 4; - break; - case 'C': - s = va_arg(ap, char *); - head_size += str_charnum(s) + 1; - break; - } - } - va_end(ap); - - /* allocate the space, then scan the format again to fill in the values */ - *blob = data_blob_talloc(mem_ctx, NULL, head_size + data_size); - - if (blob->length != (head_size + data_size)) { - return NT_STATUS_NO_MEMORY; - } - - head_ofs = 0; - data_ofs = head_size; - - va_start(ap, format); - for (i=0; format[i]; i++) { - switch (format[i]) { - case 'U': - s = va_arg(ap, char *); - n = str_charnum(s); - SSVAL(blob->data, head_ofs, n*2); head_ofs += 2; - SSVAL(blob->data, head_ofs, n*2); head_ofs += 2; - SIVAL(blob->data, head_ofs, data_ofs); head_ofs += 4; - push_string(NULL, blob->data+data_ofs, s, n*2, STR_UNICODE|STR_NOALIGN); - data_ofs += n*2; - break; - case 'A': - s = va_arg(ap, char *); - n = str_ascii_charnum(s); - SSVAL(blob->data, head_ofs, n); head_ofs += 2; - SSVAL(blob->data, head_ofs, n); head_ofs += 2; - SIVAL(blob->data, head_ofs, data_ofs); head_ofs += 4; - push_string(NULL, blob->data+data_ofs, s, n, STR_ASCII|STR_NOALIGN); - data_ofs += n; - break; - case 'a': - n = va_arg(ap, int); - SSVAL(blob->data, data_ofs, n); data_ofs += 2; - s = va_arg(ap, char *); - n = str_charnum(s); - SSVAL(blob->data, data_ofs, n*2); data_ofs += 2; - if (0 < n) { - push_string(NULL, blob->data+data_ofs, s, n*2, - STR_UNICODE|STR_NOALIGN); - } - data_ofs += n*2; - break; - - case 'B': - b = va_arg(ap, uint8_t *); - n = va_arg(ap, int); - SSVAL(blob->data, head_ofs, n); head_ofs += 2; - SSVAL(blob->data, head_ofs, n); head_ofs += 2; - SIVAL(blob->data, head_ofs, data_ofs); head_ofs += 4; - if (n && b) /* don't follow null pointers... */ - memcpy(blob->data+data_ofs, b, n); - data_ofs += n; - break; - case 'd': - n = va_arg(ap, int); - SIVAL(blob->data, head_ofs, n); head_ofs += 4; - break; - case 'b': - b = va_arg(ap, uint8_t *); - n = va_arg(ap, int); - memcpy(blob->data + head_ofs, b, n); - head_ofs += n; - break; - case 'C': - s = va_arg(ap, char *); - head_ofs += push_string(NULL, blob->data+head_ofs, s, -1, - STR_ASCII|STR_TERMINATE); - break; - } - } - va_end(ap); - - return NT_STATUS_OK; -} - - -/* a helpful macro to avoid running over the end of our blob */ -#define NEED_DATA(amount) \ -if ((head_ofs + amount) > blob->length) { \ - return NT_STATUS_INVALID_PARAMETER; \ -} - -/* - this is a tiny msrpc packet parser. This the the partner of msrpc_gen - - format specifiers are: - - U = unicode string (output is unix string) - A = ascii string - B = data blob - b = data blob in header - d = word (4 bytes) - C = constant ascii string - */ - -NTSTATUS ndr_pull_format_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, - const char *format, ...) -{ - int i; - va_list ap; - const char **ps, *s; - DATA_BLOB *b; - size_t head_ofs = 0; - uint16_t len1, len2; - uint32_t ptr; - uint32_t *v; - pstring p; - - va_start(ap, format); - for (i=0; format[i]; i++) { - switch (format[i]) { - case 'U': - NEED_DATA(8); - len1 = SVAL(blob->data, head_ofs); head_ofs += 2; - len2 = SVAL(blob->data, head_ofs); head_ofs += 2; - ptr = IVAL(blob->data, head_ofs); head_ofs += 4; - - ps = va_arg(ap, char **); - if (len1 == 0 && len2 == 0) { - *ps = ""; - } else { - /* make sure its in the right format - be strict */ - if ((len1 != len2) || (ptr + len1 < ptr) || (ptr + len1 < len1) || (ptr + len1 > blob->length)) { - return NT_STATUS_INVALID_PARAMETER; - } - if (len1 & 1) { - /* if odd length and unicode */ - return NT_STATUS_INVALID_PARAMETER; - } - if (blob->data + ptr < (uint8_t *)ptr || blob->data + ptr < blob->data) - return NT_STATUS_INVALID_PARAMETER; - - if (0 < len1) { - pull_string(NULL, p, blob->data + ptr, sizeof(p), - len1, - STR_UNICODE|STR_NOALIGN); - (*ps) = talloc_strdup(mem_ctx, p); - if (!(*ps)) { - return NT_STATUS_NO_MEMORY; - } - } else { - (*ps) = ""; - } - } - break; - case 'A': - NEED_DATA(8); - len1 = SVAL(blob->data, head_ofs); head_ofs += 2; - len2 = SVAL(blob->data, head_ofs); head_ofs += 2; - ptr = IVAL(blob->data, head_ofs); head_ofs += 4; - - ps = va_arg(ap, char **); - /* make sure its in the right format - be strict */ - if (len1 == 0 && len2 == 0) { - *ps = ""; - } else { - if ((len1 != len2) || (ptr + len1 < ptr) || (ptr + len1 < len1) || (ptr + len1 > blob->length)) { - return NT_STATUS_INVALID_PARAMETER; - } - - if (blob->data + ptr < (uint8_t *)ptr || blob->data + ptr < blob->data) - return NT_STATUS_INVALID_PARAMETER; - - if (0 < len1) { - pull_string(NULL, p, blob->data + ptr, sizeof(p), - len1, - STR_ASCII|STR_NOALIGN); - (*ps) = talloc_strdup(mem_ctx, p); - if (!(*ps)) { - return NT_STATUS_NO_MEMORY; - } - } else { - (*ps) = ""; - } - } - break; - case 'B': - NEED_DATA(8); - len1 = SVAL(blob->data, head_ofs); head_ofs += 2; - len2 = SVAL(blob->data, head_ofs); head_ofs += 2; - ptr = IVAL(blob->data, head_ofs); head_ofs += 4; - - b = (DATA_BLOB *)va_arg(ap, void *); - if (len1 == 0 && len2 == 0) { - *b = data_blob_talloc(mem_ctx, NULL, 0); - } else { - /* make sure its in the right format - be strict */ - if ((len1 != len2) || (ptr + len1 < ptr) || (ptr + len1 < len1) || (ptr + len1 > blob->length)) { - return NT_STATUS_INVALID_PARAMETER; - } - - if (blob->data + ptr < (uint8_t *)ptr || blob->data + ptr < blob->data) - return NT_STATUS_INVALID_PARAMETER; - - *b = data_blob_talloc(mem_ctx, blob->data + ptr, len1); - } - break; - case 'b': - b = (DATA_BLOB *)va_arg(ap, void *); - len1 = va_arg(ap, uint_t); - /* make sure its in the right format - be strict */ - NEED_DATA(len1); - if (blob->data + head_ofs < (uint8_t *)head_ofs || blob->data + head_ofs < blob->data) - return NT_STATUS_INVALID_PARAMETER; - - *b = data_blob_talloc(mem_ctx, blob->data + head_ofs, len1); - head_ofs += len1; - break; - case 'd': - v = va_arg(ap, uint32_t *); - NEED_DATA(4); - *v = IVAL(blob->data, head_ofs); head_ofs += 4; - break; - case 'C': - s = va_arg(ap, char *); - - if (blob->data + head_ofs < (uint8_t *)head_ofs || blob->data + head_ofs < blob->data) - return NT_STATUS_INVALID_PARAMETER; - - head_ofs += pull_string(NULL, p, blob->data+head_ofs, sizeof(p), - blob->length - head_ofs, - STR_ASCII|STR_TERMINATE); - if (strcmp(s, p) != 0) { - return NT_STATUS_INVALID_PARAMETER; - } - break; - } - } - va_end(ap); - - return NT_STATUS_OK; -} -- cgit From 1d3b81e6c0c4c654c7395fe84b053cd77ef7d81a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 11 Aug 2004 19:48:36 +0000 Subject: r1736: - Pidl updates: - Support for "object oriented" interfaces in pidl - Support for inherited interfaces in pidl - Simplification of the support for properties on an interface - Start on dcom rpc torture tests (This used to be commit 45c3d0036b8510102816f9cdff9210098259cc5f) --- source4/librpc/ndr/ndr_basic.c | 48 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 5d4ade096f..bf72e0ad8b 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -206,6 +206,21 @@ NTSTATUS ndr_pull_array_uint32(struct ndr_pull *ndr, int ndr_flags, uint32_t *da return NT_STATUS_OK; } +/* + pull a const array of HYPER_T +*/ +NTSTATUS ndr_pull_array_HYPER_T(struct ndr_pull *ndr, int ndr_flags, HYPER_T *data, uint32_t n) +{ + uint32_t i; + if (!(ndr_flags & NDR_SCALARS)) { + return NT_STATUS_OK; + } + for (i=0;iprint(ndr, "UNKNOWN LEVEL %u", level); } +void ndr_print_array_HYPER_T(struct ndr_print *ndr, const char *name, + const HYPER_T *data, uint32_t count) +{ + int i; + + ndr->print(ndr, "%s: ARRAY(%d)", name, count); + ndr->depth++; + for (i=0;idepth--; +} + void ndr_print_array_uint32(struct ndr_print *ndr, const char *name, const uint32_t *data, uint32_t count) { -- cgit From e2357c67f5afbfeacafab6997b57ea262cd3c05a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 12 Aug 2004 05:15:41 +0000 Subject: r1757: much simpler (and smaller, faster etc) way of doing relative pointers in pidl. This mechanism should be much easier to extend to the "retrospective subcontexts" that jelmer needs. also produced more standards complient full-pointer offsets. This keeps ethereal happy with decoding our epmapper frames. (This used to be commit ecb7378bbcd86727aedfa04a9e302e06b0a2ccd9) --- source4/librpc/ndr/ndr_basic.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index bf72e0ad8b..88a58e91fd 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -72,6 +72,9 @@ NTSTATUS ndr_pull_ptr(struct ndr_pull *ndr, uint32_t *v) { NTSTATUS status; status = ndr_pull_uint32(ndr, v); + if (*v != 0) { + ndr->ptr_count++; + } return status; } -- cgit From 07eab5018034ead7d5fd033372d16f1a29c35ef0 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 17 Aug 2004 09:14:46 +0000 Subject: r1847: add STR_BYTESIZE flag, to handle cases where the size is in bytes not in unicode chars metze (This used to be commit 6d094d60d377479de28790bad8ceb4c083c902cd) --- source4/librpc/ndr/ndr_basic.c | 58 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 6 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 88a58e91fd..d495bf2946 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -472,6 +472,7 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) break; case LIBNDR_FLAG_STR_SIZE4: + case LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_NOTERM: NDR_CHECK(ndr_pull_uint32(ndr, &len1)); NDR_PULL_NEED_BYTES(ndr, len1*2); if (len1 == 0) { @@ -487,6 +488,37 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) "Bad character conversion"); } NDR_CHECK(ndr_pull_advance(ndr, len1*2)); + + /* this is a way of detecting if a string is sent with the wrong + termination */ + if (ndr->flags & LIBNDR_FLAG_STR_NOTERM) { + if (strlen(as) < len1) { + DEBUG(6,("short string '%s'\n", as)); + } + } else { + if (strlen(as) == len1) { + DEBUG(6,("long string '%s'\n", as)); + } + } + *s = as; + break; + + case LIBNDR_FLAG_STR_SIZE2|LIBNDR_FLAG_STR_NOTERM|LIBNDR_FLAG_STR_BYTESIZE: + NDR_CHECK(ndr_pull_uint16(ndr, &len3)); + NDR_PULL_NEED_BYTES(ndr, len3); + if (len3 == 0) { + *s = talloc_strdup(ndr->mem_ctx, ""); + break; + } + ret = convert_string_talloc(ndr->mem_ctx, chset, CH_UNIX, + ndr->data+ndr->offset, + len3, + (const void **)&as); + if (ret == -1) { + return ndr_pull_error(ndr, NDR_ERR_CHARCNV, + "Bad character conversion"); + } + NDR_CHECK(ndr_pull_advance(ndr, len3)); *s = as; break; @@ -499,12 +531,13 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) ret = convert_string_talloc(ndr->mem_ctx, chset, CH_UNIX, ndr->data+ndr->offset, len1*2, - (const void **)s); + (const void **)&as); if (ret == -1) { return ndr_pull_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); } NDR_CHECK(ndr_pull_advance(ndr, len1*2)); + *s = as; break; case LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4: @@ -520,7 +553,7 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) NDR_ALLOC_N(ndr, as, (len2+1)); NDR_CHECK(ndr_pull_bytes(ndr, as, len2)); as[len2] = 0; - (*s) = as; + *s = as; break; case LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_LEN4: @@ -529,7 +562,7 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) NDR_ALLOC_N(ndr, as, (len2+1)); NDR_CHECK(ndr_pull_bytes(ndr, as, len2)); as[len2] = 0; - (*s) = as; + *s = as; break; case LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_SIZE2: @@ -537,7 +570,7 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) NDR_ALLOC_N(ndr, as, (len3+1)); NDR_CHECK(ndr_pull_bytes(ndr, as, len3)); as[len3] = 0; - (*s) = as; + *s = as; break; case LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM: @@ -548,7 +581,7 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) NDR_ALLOC_N(ndr, as, (len1+1)); NDR_CHECK(ndr_pull_bytes(ndr, as, len1)); as[len1] = 0; - (*s) = as; + *s = as; break; default: @@ -635,7 +668,20 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) } ndr->offset += c_len*2 + 2; break; - + + case LIBNDR_FLAG_STR_SIZE2|LIBNDR_FLAG_STR_NOTERM|LIBNDR_FLAG_STR_BYTESIZE: + NDR_CHECK(ndr_push_uint16(ndr, c_len*2)); + NDR_PUSH_NEED_BYTES(ndr, c_len*2); + ret = convert_string(CH_UNIX, chset, + s, s_len, + ndr->data+ndr->offset, c_len*2); + if (ret == -1) { + return ndr_push_error(ndr, NDR_ERR_CHARCNV, + "Bad character conversion"); + } + ndr->offset += c_len*2; + break; + case LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4: NDR_CHECK(ndr_push_uint32(ndr, c_len+1)); NDR_CHECK(ndr_push_uint32(ndr, 0)); -- cgit From b7e1ea20dc873a753ff64653987130f03897a4e9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 21 Aug 2004 07:43:29 +0000 Subject: r1985: take advantage of the new talloc in a few more places (This used to be commit 6ffdfd779936ce8c5ca49c5f444e8da2bbeee0a8) --- source4/librpc/ndr/ndr_basic.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index d495bf2946..43c469d4c5 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -443,11 +443,11 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) len1, ofs, len2); } if (len2 == 0) { - *s = talloc_strdup(ndr->mem_ctx, ""); + *s = talloc_strdup(ndr, ""); break; } NDR_PULL_NEED_BYTES(ndr, len2*2); - ret = convert_string_talloc(ndr->mem_ctx, chset, CH_UNIX, + ret = convert_string_talloc(ndr, chset, CH_UNIX, ndr->data+ndr->offset, len2*2, (const void **)&as); @@ -476,10 +476,10 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) NDR_CHECK(ndr_pull_uint32(ndr, &len1)); NDR_PULL_NEED_BYTES(ndr, len1*2); if (len1 == 0) { - *s = talloc_strdup(ndr->mem_ctx, ""); + *s = talloc_strdup(ndr, ""); break; } - ret = convert_string_talloc(ndr->mem_ctx, chset, CH_UNIX, + ret = convert_string_talloc(ndr, chset, CH_UNIX, ndr->data+ndr->offset, len1*2, (const void **)&as); @@ -507,10 +507,10 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) NDR_CHECK(ndr_pull_uint16(ndr, &len3)); NDR_PULL_NEED_BYTES(ndr, len3); if (len3 == 0) { - *s = talloc_strdup(ndr->mem_ctx, ""); + *s = talloc_strdup(ndr, ""); break; } - ret = convert_string_talloc(ndr->mem_ctx, chset, CH_UNIX, + ret = convert_string_talloc(ndr, chset, CH_UNIX, ndr->data+ndr->offset, len3, (const void **)&as); @@ -528,7 +528,7 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) if (len1*2+2 <= ndr->data_size - ndr->offset) { len1++; } - ret = convert_string_talloc(ndr->mem_ctx, chset, CH_UNIX, + ret = convert_string_talloc(ndr, chset, CH_UNIX, ndr->data+ndr->offset, len1*2, (const void **)&as); @@ -855,7 +855,7 @@ void ndr_print_string(struct ndr_print *ndr, const char *name, const char *s) void ndr_print_NTTIME(struct ndr_print *ndr, const char *name, NTTIME t) { - ndr->print(ndr, "%-25s: %s", name, nt_time_string(ndr->mem_ctx, t)); + ndr->print(ndr, "%-25s: %s", name, nt_time_string(ndr, t)); } void ndr_print_time_t(struct ndr_print *ndr, const char *name, time_t t) @@ -863,7 +863,7 @@ void ndr_print_time_t(struct ndr_print *ndr, const char *name, time_t t) if (t == (time_t)-1 || t == 0) { ndr->print(ndr, "%-25s: (time_t)%d", name, (int)t); } else { - ndr->print(ndr, "%-25s: %s", name, timestring(ndr->mem_ctx, t)); + ndr->print(ndr, "%-25s: %s", name, timestring(ndr, t)); } } @@ -1007,7 +1007,7 @@ const char *GUID_string(TALLOC_CTX *mem_ctx, const struct GUID *guid) void ndr_print_GUID(struct ndr_print *ndr, const char *name, const struct GUID *guid) { - ndr->print(ndr, "%-25s: %s", name, GUID_string(ndr->mem_ctx, guid)); + ndr->print(ndr, "%-25s: %s", name, GUID_string(ndr, guid)); } void ndr_print_DATA_BLOB(struct ndr_print *ndr, const char *name, DATA_BLOB r) @@ -1065,7 +1065,7 @@ NTSTATUS ndr_pull_DATA_BLOB(struct ndr_pull *ndr, DATA_BLOB *blob) NDR_CHECK(ndr_pull_uint32(ndr, &length)); } NDR_PULL_NEED_BYTES(ndr, length); - *blob = data_blob_talloc(ndr->mem_ctx, ndr->data+ndr->offset, length); + *blob = data_blob_talloc(ndr, ndr->data+ndr->offset, length); ndr->offset += length; return NT_STATUS_OK; } -- cgit From ae95563caf8f1c3e1ae4c88558732520c2c5df06 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 23 Aug 2004 07:08:07 +0000 Subject: r1994: fix compiler warning metze (This used to be commit a3a4b9c9ea2692b3ca85d9a4a094e36609831f19) --- source4/librpc/ndr/ndr_basic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 43c469d4c5..34a1935c3b 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -523,7 +523,7 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) break; case LIBNDR_FLAG_STR_NULLTERM: - len1 = strnlen_w(ndr->data+ndr->offset, + len1 = strnlen_w((const smb_ucs2_t *)ndr->data+ndr->offset, (ndr->data_size - ndr->offset)/2); if (len1*2+2 <= ndr->data_size - ndr->offset) { len1++; -- cgit From 31c1c7846f6b6e5848bc39a28a65118bfa98e35d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 1 Sep 2004 04:39:06 +0000 Subject: r2159: converted samba4 over to UTF-16. I had previously thought this was unnecessary, as windows doesn't use standards compliant UTF-16, and for filesystem operations treats bytes as UCS-2, but Bjoern Jacke has pointed out to me that this means we don't correctly store extended UTF-16 characters as UTF-8 on disk. This can be seen with (for example) the gothic characters with codepoints above 64k. This commit also adds a LOCAL-ICONV torture test that tests the first 1 million codepoints against the system iconv library, and tests 5 million random UTF-16LE buffers for identical error handling to the system iconv library. the lib/iconv.c changes need backporting to samba3 (This used to be commit 756f28ac95feaa84b42402723d5f7286865c78db) --- source4/librpc/ndr/ndr_basic.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 34a1935c3b..7f36f7e4ba 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -421,14 +421,14 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) uint32_t len1, ofs, len2; uint16_t len3; int ret; - int chset = CH_UCS2; + int chset = CH_UTF16; if (!(ndr_flags & NDR_SCALARS)) { return NT_STATUS_OK; } if (NDR_BE(ndr)) { - chset = CH_UCS2BE; + chset = CH_UTF16BE; } switch (ndr->flags & LIBNDR_STRING_FLAGS) { @@ -600,14 +600,14 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) { ssize_t s_len, c_len; int ret; - int chset = CH_UCS2; + int chset = CH_UTF16; if (!(ndr_flags & NDR_SCALARS)) { return NT_STATUS_OK; } if (NDR_BE(ndr)) { - chset = CH_UCS2BE; + chset = CH_UTF16BE; } s_len = s?strlen(s):0; -- cgit From 4d390df586ff1b4ba4b5bbfbde3c6393c6f5c829 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 2 Sep 2004 10:45:58 +0000 Subject: r2180: added RPC flags "padcheck" which enables checking of all received pad bytes to make sure they are zero. Non-zero values usually indicate one of two things: - the server is leaking data through sending uninitialised memory - we have mistaken a real field in the IDL for padding to differentiate between the two you really need to run with "print,padcheck" and look carefully at whether the non-zero pad bytes are random or appear to be deliberate. (This used to be commit 7fdb778f81f14aaab75ab204431e4342a462957a) --- source4/librpc/ndr/ndr_basic.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 7f36f7e4ba..d015cc5e48 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -28,6 +28,31 @@ #define NDR_SSVAL(ndr, ofs, v) do { if (NDR_BE(ndr)) { RSSVAL(ndr->data,ofs,v); } else SSVAL(ndr->data,ofs,v); } while (0) #define NDR_SIVAL(ndr, ofs, v) do { if (NDR_BE(ndr)) { RSIVAL(ndr->data,ofs,v); } else SIVAL(ndr->data,ofs,v); } while (0) + +/* + check for data leaks from the server by looking for non-zero pad bytes + these could also indicate that real structure elements have been + mistaken for padding in the IDL +*/ +void ndr_check_padding(struct ndr_pull *ndr, size_t n) +{ + size_t ofs2 = (ndr->offset + (n-1)) & ~(n-1); + int i; + for (i=ndr->offset;idata[i] != 0) { + break; + } + } + if (ioffset;idata[i])); + } + DEBUG(0,("\n")); + } + +} + /* parse a uint8 */ -- cgit From d0aee368a13191b456437c169b22187cd6c52ba8 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 3 Sep 2004 12:52:04 +0000 Subject: r2205: fixed an incorrect cast that broke relative strings in spoolss (This used to be commit d2d3433de1c1e1bc757381e9736147cc24fe8cf0) --- source4/librpc/ndr/ndr_basic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index d015cc5e48..01205d4043 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -548,7 +548,7 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) break; case LIBNDR_FLAG_STR_NULLTERM: - len1 = strnlen_w((const smb_ucs2_t *)ndr->data+ndr->offset, + len1 = strnlen_w((const smb_ucs2_t *)(ndr->data+ndr->offset), (ndr->data_size - ndr->offset)/2); if (len1*2+2 <= ndr->data_size - ndr->offset) { len1++; -- cgit From 9a9dcc7250ccd4544cb797c15b3bc3dfbb760be0 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 23 Sep 2004 00:51:45 +0000 Subject: r2552: Character set conversion and string handling updates. The intial motivation for this commit was to merge in some of the bugfixes present in Samba3's chrcnv and string handling code into Samba4. However, along the way I found a lot of unused functions, and decided to do a bit more... The strlen_m code now does not use a fixed buffer, but more work is needed to finish off other functions in str_util.c. These fixed length buffers hav caused very nasty, hard to chase down bugs at some sites. The strupper_m() function has a strupper_talloc() to replace it (we need to go around and fix more uses, but it's a start). Use of these new functions will avoid bugs where the upper or lowercase version of a string is a different length. I have removed the push_*_allocate functions, which are replaced by calls to push_*_talloc. Likewise, pstring and other 'fixed length' wrappers are removed, where possible. I have removed the first ('base pointer') argument, used by push_ucs2, as the Samba4 way of doing things ensures that this is always on an even boundary anyway. (It was used in only one place, in any case). (This used to be commit dfecb0150627b500cb026b8a4932fe87902ca392) --- source4/librpc/ndr/ndr_basic.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 01205d4043..6ff996b553 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -475,7 +475,7 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) ret = convert_string_talloc(ndr, chset, CH_UNIX, ndr->data+ndr->offset, len2*2, - (const void **)&as); + (void **)&as); if (ret == -1) { return ndr_pull_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); @@ -507,7 +507,7 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) ret = convert_string_talloc(ndr, chset, CH_UNIX, ndr->data+ndr->offset, len1*2, - (const void **)&as); + (void **)&as); if (ret == -1) { return ndr_pull_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); @@ -538,7 +538,7 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) ret = convert_string_talloc(ndr, chset, CH_UNIX, ndr->data+ndr->offset, len3, - (const void **)&as); + (void **)&as); if (ret == -1) { return ndr_pull_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); @@ -556,7 +556,7 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) ret = convert_string_talloc(ndr, chset, CH_UNIX, ndr->data+ndr->offset, len1*2, - (const void **)&as); + (void **)&as); if (ret == -1) { return ndr_pull_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); -- cgit From 7d32679e9683c81aca538f0267684332a28a286f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 8 Oct 2004 08:13:00 +0000 Subject: r2857: this commit gets rid of smb_ucs2_t, wpstring and fpstring, plus lots of associated functions. The motivation for this change was to avoid having to convert to/from ucs2 strings for so many operations. Doing that was slow, used many static buffers, and was also incorrect as it didn't cope properly with unicode codepoints above 65536 (which could not be represented correctly as smb_ucs2_t chars) The two core functions that allowed this change are next_codepoint() and push_codepoint(). These functions allow you to correctly walk a arbitrary multi-byte string a character at a time without converting the whole string to ucs2. While doing this cleanup I also fixed several ucs2 string handling bugs. See the commit for details. The following code (which counts the number of occuraces of 'c' in a string) shows how to use the new interface: size_t count_chars(const char *s, char c) { size_t count = 0; while (*s) { size_t size; codepoint_t c2 = next_codepoint(s, &size); if (c2 == c) count++; s += size; } return count; } (This used to be commit 814881f0e50019196b3aa9fbe4aeadbb98172040) --- source4/librpc/ndr/ndr_basic.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 6ff996b553..9321f932c4 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -548,20 +548,16 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) break; case LIBNDR_FLAG_STR_NULLTERM: - len1 = strnlen_w((const smb_ucs2_t *)(ndr->data+ndr->offset), - (ndr->data_size - ndr->offset)/2); - if (len1*2+2 <= ndr->data_size - ndr->offset) { - len1++; - } + len1 = utf16_len_n(ndr->data+ndr->offset, ndr->data_size - ndr->offset); ret = convert_string_talloc(ndr, chset, CH_UNIX, ndr->data+ndr->offset, - len1*2, + len1, (void **)&as); if (ret == -1) { return ndr_pull_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); } - NDR_CHECK(ndr_pull_advance(ndr, len1*2)); + NDR_CHECK(ndr_pull_advance(ndr, len1)); *s = as; break; -- cgit From d186e63b01e0f14c1e7a7709c44e534efbb1fc36 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 11 Oct 2004 09:27:19 +0000 Subject: r2910: I noticed that the samr torture test was doing its own DOS->UNIX string conversion. For RPC, all string conversions are supposed to be done by the NDR layer, using string flags set in the IDL. The reason this wasn't working is that I had been too lazy to do the STR_ASCII string types properly at the NDR layer when initially writing ndr_basic.c. This commit fixes the ndr_basic code properly to do all ASCII varients, by re-using the non-ascii code and a "byte_mul" local variable. I have also removed the manual string conversion in the SAMR torture test code. (This used to be commit aad0e7e9d890bb56447f1f933b8f2bb78a3ee269) --- source4/librpc/ndr/ndr_basic.c | 267 +++++++++++++++++++++-------------------- 1 file changed, 138 insertions(+), 129 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 9321f932c4..04b788acf3 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -447,6 +447,8 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) uint16_t len3; int ret; int chset = CH_UTF16; + unsigned byte_mul = 2; + unsigned flags = ndr->flags; if (!(ndr_flags & NDR_SCALARS)) { return NT_STATUS_OK; @@ -456,11 +458,21 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) chset = CH_UTF16BE; } - switch (ndr->flags & LIBNDR_STRING_FLAGS) { + if (flags & LIBNDR_FLAG_STR_ASCII) { + chset = CH_DOS; + byte_mul = 1; + flags &= ~LIBNDR_FLAG_STR_ASCII; + } + + switch (flags & LIBNDR_STRING_FLAGS) { case LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4: case LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_NOTERM: NDR_CHECK(ndr_pull_uint32(ndr, &len1)); NDR_CHECK(ndr_pull_uint32(ndr, &ofs)); + if (ofs != 0) { + return ndr_pull_error(ndr, NDR_ERR_STRING, "non-zero array offset with string flags 0x%x\n", + ndr->flags & LIBNDR_STRING_FLAGS); + } NDR_CHECK(ndr_pull_uint32(ndr, &len2)); if (len2 > len1) { return ndr_pull_error(ndr, NDR_ERR_STRING, @@ -471,16 +483,16 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) *s = talloc_strdup(ndr, ""); break; } - NDR_PULL_NEED_BYTES(ndr, len2*2); + NDR_PULL_NEED_BYTES(ndr, len2*byte_mul); ret = convert_string_talloc(ndr, chset, CH_UNIX, ndr->data+ndr->offset, - len2*2, + len2*byte_mul, (void **)&as); if (ret == -1) { return ndr_pull_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); } - NDR_CHECK(ndr_pull_advance(ndr, len2*2)); + NDR_CHECK(ndr_pull_advance(ndr, len2*byte_mul)); /* this is a way of detecting if a string is sent with the wrong termination */ @@ -499,20 +511,20 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) case LIBNDR_FLAG_STR_SIZE4: case LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_NOTERM: NDR_CHECK(ndr_pull_uint32(ndr, &len1)); - NDR_PULL_NEED_BYTES(ndr, len1*2); + NDR_PULL_NEED_BYTES(ndr, len1*byte_mul); if (len1 == 0) { *s = talloc_strdup(ndr, ""); break; } ret = convert_string_talloc(ndr, chset, CH_UNIX, ndr->data+ndr->offset, - len1*2, + len1*byte_mul, (void **)&as); if (ret == -1) { return ndr_pull_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); } - NDR_CHECK(ndr_pull_advance(ndr, len1*2)); + NDR_CHECK(ndr_pull_advance(ndr, len1*byte_mul)); /* this is a way of detecting if a string is sent with the wrong termination */ @@ -528,80 +540,110 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) *s = as; break; - case LIBNDR_FLAG_STR_SIZE2|LIBNDR_FLAG_STR_NOTERM|LIBNDR_FLAG_STR_BYTESIZE: - NDR_CHECK(ndr_pull_uint16(ndr, &len3)); - NDR_PULL_NEED_BYTES(ndr, len3); - if (len3 == 0) { + case LIBNDR_FLAG_STR_LEN4: + case LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_NOTERM: + NDR_CHECK(ndr_pull_uint32(ndr, &ofs)); + if (ofs != 0) { + return ndr_pull_error(ndr, NDR_ERR_STRING, "non-zero array offset with string flags 0x%x\n", + ndr->flags & LIBNDR_STRING_FLAGS); + } + NDR_CHECK(ndr_pull_uint32(ndr, &len1)); + NDR_PULL_NEED_BYTES(ndr, len1*byte_mul); + if (len1 == 0) { *s = talloc_strdup(ndr, ""); break; } ret = convert_string_talloc(ndr, chset, CH_UNIX, ndr->data+ndr->offset, - len3, + len1*byte_mul, (void **)&as); if (ret == -1) { return ndr_pull_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); } - NDR_CHECK(ndr_pull_advance(ndr, len3)); + NDR_CHECK(ndr_pull_advance(ndr, len1*byte_mul)); + + /* this is a way of detecting if a string is sent with the wrong + termination */ + if (ndr->flags & LIBNDR_FLAG_STR_NOTERM) { + if (strlen(as) < len1) { + DEBUG(6,("short string '%s'\n", as)); + } + } else { + if (strlen(as) == len1) { + DEBUG(6,("long string '%s'\n", as)); + } + } *s = as; break; - case LIBNDR_FLAG_STR_NULLTERM: - len1 = utf16_len_n(ndr->data+ndr->offset, ndr->data_size - ndr->offset); + + case LIBNDR_FLAG_STR_SIZE2: + case LIBNDR_FLAG_STR_SIZE2|LIBNDR_FLAG_STR_NOTERM: + NDR_CHECK(ndr_pull_uint16(ndr, &len3)); + NDR_PULL_NEED_BYTES(ndr, len3*byte_mul); + if (len3 == 0) { + *s = talloc_strdup(ndr, ""); + break; + } ret = convert_string_talloc(ndr, chset, CH_UNIX, ndr->data+ndr->offset, - len1, + len3*byte_mul, (void **)&as); if (ret == -1) { return ndr_pull_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); } - NDR_CHECK(ndr_pull_advance(ndr, len1)); - *s = as; - break; + NDR_CHECK(ndr_pull_advance(ndr, len3*byte_mul)); - case LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4: - case LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_NOTERM: - NDR_CHECK(ndr_pull_uint32(ndr, &len1)); - NDR_CHECK(ndr_pull_uint32(ndr, &ofs)); - NDR_CHECK(ndr_pull_uint32(ndr, &len2)); - if (len2 > len1) { - return ndr_pull_error(ndr, NDR_ERR_STRING, - "Bad ascii string lengths len1=%u ofs=%u len2=%u\n", - len1, ofs, len2); + /* this is a way of detecting if a string is sent with the wrong + termination */ + if (ndr->flags & LIBNDR_FLAG_STR_NOTERM) { + if (strlen(as) < len3) { + DEBUG(6,("short string '%s'\n", as)); + } + } else { + if (strlen(as) == len3) { + DEBUG(6,("long string '%s'\n", as)); + } } - NDR_ALLOC_N(ndr, as, (len2+1)); - NDR_CHECK(ndr_pull_bytes(ndr, as, len2)); - as[len2] = 0; - *s = as; - break; - - case LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_LEN4: - NDR_CHECK(ndr_pull_uint32(ndr, &ofs)); - NDR_CHECK(ndr_pull_uint32(ndr, &len2)); - NDR_ALLOC_N(ndr, as, (len2+1)); - NDR_CHECK(ndr_pull_bytes(ndr, as, len2)); - as[len2] = 0; *s = as; break; - case LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_SIZE2: + case LIBNDR_FLAG_STR_SIZE2|LIBNDR_FLAG_STR_NOTERM|LIBNDR_FLAG_STR_BYTESIZE: NDR_CHECK(ndr_pull_uint16(ndr, &len3)); - NDR_ALLOC_N(ndr, as, (len3+1)); - NDR_CHECK(ndr_pull_bytes(ndr, as, len3)); - as[len3] = 0; + NDR_PULL_NEED_BYTES(ndr, len3); + if (len3 == 0) { + *s = talloc_strdup(ndr, ""); + break; + } + ret = convert_string_talloc(ndr, chset, CH_UNIX, + ndr->data+ndr->offset, + len3, + (void **)&as); + if (ret == -1) { + return ndr_pull_error(ndr, NDR_ERR_CHARCNV, + "Bad character conversion"); + } + NDR_CHECK(ndr_pull_advance(ndr, len3)); *s = as; break; - case LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM: - len1 = strnlen(ndr->data+ndr->offset, (ndr->data_size - ndr->offset)); - if (len1+1 <= ndr->data_size - ndr->offset) { - len1++; + case LIBNDR_FLAG_STR_NULLTERM: + if (byte_mul == 1) { + len1 = strnlen(ndr->data+ndr->offset, ndr->data_size - ndr->offset); + } else { + len1 = utf16_len_n(ndr->data+ndr->offset, ndr->data_size - ndr->offset); + } + ret = convert_string_talloc(ndr, chset, CH_UNIX, + ndr->data+ndr->offset, + len1, + (void **)&as); + if (ret == -1) { + return ndr_pull_error(ndr, NDR_ERR_CHARCNV, + "Bad character conversion"); } - NDR_ALLOC_N(ndr, as, (len1+1)); - NDR_CHECK(ndr_pull_bytes(ndr, as, len1)); - as[len1] = 0; + NDR_CHECK(ndr_pull_advance(ndr, len1)); *s = as; break; @@ -622,6 +664,8 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) ssize_t s_len, c_len; int ret; int chset = CH_UTF16; + unsigned flags = ndr->flags; + unsigned byte_mul = 2; if (!(ndr_flags & NDR_SCALARS)) { return NT_STATUS_OK; @@ -634,142 +678,107 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) s_len = s?strlen(s):0; c_len = s?strlen_m(s):0; - switch (ndr->flags & LIBNDR_STRING_FLAGS) { + if (flags & LIBNDR_FLAG_STR_ASCII) { + chset = CH_DOS; + byte_mul = 1; + flags &= ~LIBNDR_FLAG_STR_ASCII; + } + + switch (flags & LIBNDR_STRING_FLAGS) { case LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4: NDR_CHECK(ndr_push_uint32(ndr, c_len+1)); NDR_CHECK(ndr_push_uint32(ndr, 0)); NDR_CHECK(ndr_push_uint32(ndr, c_len+1)); - NDR_PUSH_NEED_BYTES(ndr, c_len*2 + 2); + NDR_PUSH_NEED_BYTES(ndr, byte_mul*(c_len+1)); ret = convert_string(CH_UNIX, chset, s, s_len+1, - ndr->data+ndr->offset, c_len*2 + 2); + ndr->data+ndr->offset, + byte_mul*(c_len+1)); if (ret == -1) { return ndr_push_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); } - ndr->offset += c_len*2 + 2; + ndr->offset += byte_mul*(c_len+1); break; case LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_NOTERM: NDR_CHECK(ndr_push_uint32(ndr, c_len)); NDR_CHECK(ndr_push_uint32(ndr, 0)); NDR_CHECK(ndr_push_uint32(ndr, c_len)); - NDR_PUSH_NEED_BYTES(ndr, c_len*2); + NDR_PUSH_NEED_BYTES(ndr, c_len*byte_mul); ret = convert_string(CH_UNIX, chset, s, s_len, - ndr->data+ndr->offset, c_len*2); + ndr->data+ndr->offset, c_len*byte_mul); if (ret == -1) { return ndr_push_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); } - ndr->offset += c_len*2; + ndr->offset += c_len*byte_mul; break; - case LIBNDR_FLAG_STR_SIZE4: + case LIBNDR_FLAG_STR_LEN4: + NDR_CHECK(ndr_push_uint32(ndr, 0)); NDR_CHECK(ndr_push_uint32(ndr, c_len + 1)); - NDR_PUSH_NEED_BYTES(ndr, c_len*2 + 2); + NDR_PUSH_NEED_BYTES(ndr, byte_mul*(c_len+1)); ret = convert_string(CH_UNIX, chset, s, s_len + 1, - ndr->data+ndr->offset, c_len*2 + 2); - if (ret == -1) { - return ndr_push_error(ndr, NDR_ERR_CHARCNV, - "Bad character conversion"); - } - ndr->offset += c_len*2 + 2; - break; - - case LIBNDR_FLAG_STR_NULLTERM: - NDR_PUSH_NEED_BYTES(ndr, c_len*2 + 2); - ret = convert_string(CH_UNIX, chset, - s, s_len+1, - ndr->data+ndr->offset, c_len*2 + 2); + ndr->data+ndr->offset, byte_mul*(c_len+1)); if (ret == -1) { return ndr_push_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); } - ndr->offset += c_len*2 + 2; + ndr->offset += byte_mul*(c_len+1); break; - case LIBNDR_FLAG_STR_SIZE2|LIBNDR_FLAG_STR_NOTERM|LIBNDR_FLAG_STR_BYTESIZE: - NDR_CHECK(ndr_push_uint16(ndr, c_len*2)); - NDR_PUSH_NEED_BYTES(ndr, c_len*2); + case LIBNDR_FLAG_STR_SIZE4: + NDR_CHECK(ndr_push_uint32(ndr, c_len + 1)); + NDR_PUSH_NEED_BYTES(ndr, byte_mul*(c_len+1)); ret = convert_string(CH_UNIX, chset, - s, s_len, - ndr->data+ndr->offset, c_len*2); - if (ret == -1) { - return ndr_push_error(ndr, NDR_ERR_CHARCNV, - "Bad character conversion"); - } - ndr->offset += c_len*2; - break; - - case LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4: - NDR_CHECK(ndr_push_uint32(ndr, c_len+1)); - NDR_CHECK(ndr_push_uint32(ndr, 0)); - NDR_CHECK(ndr_push_uint32(ndr, c_len+1)); - NDR_PUSH_NEED_BYTES(ndr, c_len + 1); - ret = convert_string(CH_UNIX, CH_DOS, s, s_len + 1, - ndr->data+ndr->offset, c_len + 1); - if (ret == -1) { - return ndr_push_error(ndr, NDR_ERR_CHARCNV, - "Bad character conversion"); - } - ndr->offset += c_len + 1; - break; - - case LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_NOTERM: - NDR_CHECK(ndr_push_uint32(ndr, c_len)); - NDR_CHECK(ndr_push_uint32(ndr, 0)); - NDR_CHECK(ndr_push_uint32(ndr, c_len)); - NDR_PUSH_NEED_BYTES(ndr, c_len); - ret = convert_string(CH_UNIX, CH_DOS, - s, s_len, - ndr->data+ndr->offset, c_len); + ndr->data+ndr->offset, byte_mul*(c_len+1)); if (ret == -1) { return ndr_push_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); } - ndr->offset += c_len; + ndr->offset += byte_mul*(c_len+1); break; - case LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_LEN4: - NDR_CHECK(ndr_push_uint32(ndr, 0)); - NDR_CHECK(ndr_push_uint32(ndr, c_len+1)); - NDR_PUSH_NEED_BYTES(ndr, c_len + 1); - ret = convert_string(CH_UNIX, CH_DOS, + case LIBNDR_FLAG_STR_SIZE2: + NDR_CHECK(ndr_push_uint16(ndr, c_len + 1)); + NDR_PUSH_NEED_BYTES(ndr, byte_mul*(c_len+1)); + ret = convert_string(CH_UNIX, chset, s, s_len + 1, - ndr->data+ndr->offset, c_len + 1); + ndr->data+ndr->offset, byte_mul*(c_len+1)); if (ret == -1) { return ndr_push_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); } - ndr->offset += c_len + 1; + ndr->offset += byte_mul*(c_len+1); break; - case LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_SIZE2: - NDR_CHECK(ndr_push_uint16(ndr, c_len+1)); - NDR_PUSH_NEED_BYTES(ndr, c_len + 1); - ret = convert_string(CH_UNIX, CH_DOS, - s, s_len + 1, - ndr->data+ndr->offset, c_len + 1); + case LIBNDR_FLAG_STR_NULLTERM: + NDR_PUSH_NEED_BYTES(ndr, byte_mul*(c_len+1)); + ret = convert_string(CH_UNIX, chset, + s, s_len+1, + ndr->data+ndr->offset, byte_mul*(c_len+1)); if (ret == -1) { return ndr_push_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); } - ndr->offset += c_len + 1; + ndr->offset += byte_mul*(c_len+1); break; - case LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM: - NDR_PUSH_NEED_BYTES(ndr, c_len + 1); - ret = convert_string(CH_UNIX, CH_DOS, - s, s_len+1, - ndr->data+ndr->offset, c_len + 1); + case LIBNDR_FLAG_STR_SIZE2|LIBNDR_FLAG_STR_NOTERM|LIBNDR_FLAG_STR_BYTESIZE: + NDR_CHECK(ndr_push_uint16(ndr, c_len*byte_mul)); + NDR_PUSH_NEED_BYTES(ndr, c_len*byte_mul); + ret = convert_string(CH_UNIX, chset, + s, s_len, + ndr->data+ndr->offset, c_len*byte_mul); if (ret == -1) { return ndr_push_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); } - ndr->offset += c_len + 1; + ndr->offset += c_len*byte_mul; break; default: -- cgit From f1eaf60fa3c742ab6ae9a34717adf604acbc25a0 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 15 Oct 2004 07:19:09 +0000 Subject: r2987: added support for signed 32 bit integers in pidl (This used to be commit 24122eb93e39de8db3675618b6c227c95eb58d9c) --- source4/librpc/ndr/ndr_basic.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 04b788acf3..61ad722cb1 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -25,8 +25,10 @@ #define NDR_BE(ndr) (((ndr)->flags & (LIBNDR_FLAG_BIGENDIAN|LIBNDR_FLAG_LITTLE_ENDIAN)) == LIBNDR_FLAG_BIGENDIAN) #define NDR_SVAL(ndr, ofs) (NDR_BE(ndr)?RSVAL(ndr->data,ofs):SVAL(ndr->data,ofs)) #define NDR_IVAL(ndr, ofs) (NDR_BE(ndr)?RIVAL(ndr->data,ofs):IVAL(ndr->data,ofs)) +#define NDR_IVALS(ndr, ofs) (NDR_BE(ndr)?RIVALS(ndr->data,ofs):IVALS(ndr->data,ofs)) #define NDR_SSVAL(ndr, ofs, v) do { if (NDR_BE(ndr)) { RSSVAL(ndr->data,ofs,v); } else SSVAL(ndr->data,ofs,v); } while (0) #define NDR_SIVAL(ndr, ofs, v) do { if (NDR_BE(ndr)) { RSIVAL(ndr->data,ofs,v); } else SIVAL(ndr->data,ofs,v); } while (0) +#define NDR_SIVALS(ndr, ofs, v) do { if (NDR_BE(ndr)) { RSIVALS(ndr->data,ofs,v); } else SIVALS(ndr->data,ofs,v); } while (0) /* @@ -90,6 +92,18 @@ NTSTATUS ndr_pull_uint32(struct ndr_pull *ndr, uint32_t *v) return NT_STATUS_OK; } +/* + parse a int32_t +*/ +NTSTATUS ndr_pull_int32(struct ndr_pull *ndr, int32_t *v) +{ + NDR_PULL_ALIGN(ndr, 4); + NDR_PULL_NEED_BYTES(ndr, 4); + *v = NDR_IVALS(ndr, ndr->offset); + ndr->offset += 4; + return NT_STATUS_OK; +} + /* parse a pointer */ @@ -284,6 +298,18 @@ NTSTATUS ndr_push_uint32(struct ndr_push *ndr, uint32_t v) return NT_STATUS_OK; } +/* + push a int32_t +*/ +NTSTATUS ndr_push_int32(struct ndr_push *ndr, int32_t v) +{ + NDR_PUSH_ALIGN(ndr, 4); + NDR_PUSH_NEED_BYTES(ndr, 4); + NDR_SIVALS(ndr, ndr->offset, v); + ndr->offset += 4; + return NT_STATUS_OK; +} + /* push a uint64 */ @@ -847,6 +873,11 @@ void ndr_print_uint32(struct ndr_print *ndr, const char *name, uint32_t v) ndr->print(ndr, "%-25s: 0x%08x (%u)", name, v, v); } +void ndr_print_int32(struct ndr_print *ndr, const char *name, int32_t v) +{ + ndr->print(ndr, "%-25s: %d", name, v); +} + void ndr_print_uint64(struct ndr_print *ndr, const char *name, uint64_t v) { ndr->print(ndr, "%-25s: 0x%08x%08x", name, (uint32_t)(v >> 32), (uint32_t)(v & 0xFFFFFFFF)); -- cgit From 42c810cea660f59cae8c30b12a5419450e923a2b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 15 Oct 2004 07:38:46 +0000 Subject: r2989: fix the printing of unions with negative cases when :print is used (This used to be commit d8152f896119418d95d7697cc2ca23f5319c32a9) --- source4/librpc/ndr/ndr_basic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 61ad722cb1..edb1590489 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -928,9 +928,9 @@ void ndr_print_time_t(struct ndr_print *ndr, const char *name, time_t t) } } -void ndr_print_union(struct ndr_print *ndr, const char *name, uint16_t level, const char *type) +void ndr_print_union(struct ndr_print *ndr, const char *name, int level, const char *type) { - ndr->print(ndr, "%-25s: union %s(case %u)", name, type, level); + ndr->print(ndr, "%-25s: union %s(case %d)", name, type, level); } void ndr_print_bad_level(struct ndr_print *ndr, const char *name, uint16_t level) -- cgit From fe15b46d61ee50f4225458faf963c818cde3e283 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 15 Oct 2004 09:22:21 +0000 Subject: r2990: Add support to pidl for autogenerating ndr_size_*() functions. Adding the [gensize] property to a struct or union will make pidl generate a ndr_size_*() function. (not all nasty bits of NDR are completely covered yet by the ndr_size*() functions, support for those will be added when necessary) I also have a local patch (not applied now) that simplifies the pidl output and eliminates the number of functions required. It would, however, make pidl more complex. (This used to be commit 7c823f886afd0c4c6ee838f17882ca0658417011) --- source4/librpc/ndr/ndr_basic.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index edb1590489..5808ae7452 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -1130,3 +1130,15 @@ NTSTATUS ndr_pull_DATA_BLOB(struct ndr_pull *ndr, DATA_BLOB *blob) ndr->offset += length; return NT_STATUS_OK; } + +uint32 ndr_size_DATA_BLOB(int ret, const DATA_BLOB *data, int flags) +{ + return ret + data->length; +} + +uint32 ndr_size_string(int ret, const char **string, int flags) +{ + /* FIXME: Is this correct for all strings ? */ + if(!(*string)) return ret; + return ret+strlen(*string)+1; +} -- cgit From 31e96d8def1dd2fea76d31a032d64e5917462dc8 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 20 Oct 2004 02:02:00 +0000 Subject: r3073: Fix bug in the handling of null-terminated ASCII strings in RPC. Because we didn't count the null terminator, we would not move past it in the packet. Andrew Bartlett (This used to be commit 8b38bffc7098610c469ab61b7e0e6884f046f286) --- source4/librpc/ndr/ndr_basic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 5808ae7452..239b28e3e7 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -657,7 +657,7 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) case LIBNDR_FLAG_STR_NULLTERM: if (byte_mul == 1) { - len1 = strnlen(ndr->data+ndr->offset, ndr->data_size - ndr->offset); + len1 = ascii_len_n(ndr->data+ndr->offset, ndr->data_size - ndr->offset); } else { len1 = utf16_len_n(ndr->data+ndr->offset, ndr->data_size - ndr->offset); } -- cgit From 74dd7d90622a518e54bbbdc4e37fa44cd4181e1e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 30 Oct 2004 23:19:09 +0000 Subject: r3395: added support for "string32" type, to fix the fixed width string problem that tim found. (This used to be commit 2cf35cb4d2513a7be46065e12c6fd1e2b90f4b8a) --- source4/librpc/ndr/ndr_basic.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 239b28e3e7..19db8c99a3 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -673,6 +673,22 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) *s = as; break; + case LIBNDR_FLAG_STR_FIXLEN32: + len1 = 32; + NDR_PULL_NEED_BYTES(ndr, len1*byte_mul); + ret = convert_string_talloc(ndr, chset, CH_UNIX, + ndr->data+ndr->offset, + len1*byte_mul, + (void **)&as); + if (ret == -1) { + return ndr_pull_error(ndr, NDR_ERR_CHARCNV, + "Bad character conversion"); + } + NDR_CHECK(ndr_pull_advance(ndr, len1*byte_mul)); + *s = as; + break; + + default: return ndr_pull_error(ndr, NDR_ERR_STRING, "Bad string flags 0x%x\n", ndr->flags & LIBNDR_STRING_FLAGS); @@ -807,6 +823,18 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) ndr->offset += c_len*byte_mul; break; + case LIBNDR_FLAG_STR_FIXLEN32: + NDR_PUSH_NEED_BYTES(ndr, byte_mul*32); + ret = convert_string(CH_UNIX, chset, + s, s_len + 1, + ndr->data+ndr->offset, byte_mul*32); + if (ret == -1) { + return ndr_push_error(ndr, NDR_ERR_CHARCNV, + "Bad character conversion"); + } + ndr->offset += byte_mul*32; + break; + default: return ndr_push_error(ndr, NDR_ERR_STRING, "Bad string flags 0x%x\n", ndr->flags & LIBNDR_STRING_FLAGS); -- cgit From 6ef03e7a846a4b858eec0b9953f03306f46b77e3 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 1 Nov 2004 12:40:43 +0000 Subject: r3432: Support WERROR's in arguments (not just as return type). Some of the DCOM calls are wrappers around several local calls, so you get things like: WERROR foobar ( [in] int num_ifaces, [in,size_is(num_ifaces)] IID *ifaces, [out,size_is(num_ifaces)] WERROR *results); (This used to be commit 0873bf2cbe3589988e518cf68ad4d14343b9240b) --- source4/librpc/ndr/ndr_basic.c | 54 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 19db8c99a3..95d8c28e75 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -190,9 +190,9 @@ NTSTATUS ndr_push_WERROR(struct ndr_push *ndr, WERROR status) return ndr_push_uint32(ndr, W_ERROR_V(status)); } -void ndr_print_WERROR(struct ndr_print *ndr, const char *name, WERROR *r) +void ndr_print_WERROR(struct ndr_print *ndr, const char *name, WERROR r) { - ndr->print(ndr, "%-25s: %s", name, win_errstr(*r)); + ndr->print(ndr, "%-25s: %s", name, win_errstr(r)); } /* @@ -263,6 +263,23 @@ NTSTATUS ndr_pull_array_HYPER_T(struct ndr_pull *ndr, int ndr_flags, HYPER_T *da return NT_STATUS_OK; } +/* + pull a const array of WERROR +*/ +NTSTATUS ndr_pull_array_WERROR(struct ndr_pull *ndr, int ndr_flags, WERROR *data, uint32_t n) +{ + uint32_t i; + if (!(ndr_flags & NDR_SCALARS)) { + return NT_STATUS_OK; + } + for (i=0;iprint(ndr, "UNKNOWN LEVEL %u", level); } +void ndr_print_array_WERROR(struct ndr_print *ndr, const char *name, + const WERROR *data, uint32_t count) +{ + int i; + + ndr->print(ndr, "%s: ARRAY(%d)", name, count); + ndr->depth++; + for (i=0;idepth--; +} + void ndr_print_array_HYPER_T(struct ndr_print *ndr, const char *name, const HYPER_T *data, uint32_t count) { -- cgit From a2fd2488c79902dfe1de764bea4f619ec6107fed Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 2 Nov 2004 13:46:39 +0000 Subject: r3484: - add support for conformant string arrays at the end of a struct - add support for strings where the length excludes the NULLTERM metze (This used to be commit 8251d8b3e5af351972aa41aed63f7a7d2640910e) --- source4/librpc/ndr/ndr_basic.c | 55 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 5 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 95d8c28e75..84c4ab9ddc 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -522,6 +522,9 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) flags &= ~LIBNDR_FLAG_STR_ASCII; } + flags &= ~LIBNDR_FLAG_STR_CONFORMANT; + flags &= ~LIBNDR_FLAG_STR_CHARLEN; + switch (flags & LIBNDR_STRING_FLAGS) { case LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4: case LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_NOTERM: @@ -740,6 +743,7 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) int chset = CH_UTF16; unsigned flags = ndr->flags; unsigned byte_mul = 2; + unsigned c_len_term = 1; if (!(ndr_flags & NDR_SCALARS)) { return NT_STATUS_OK; @@ -758,11 +762,18 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) flags &= ~LIBNDR_FLAG_STR_ASCII; } + flags &= ~LIBNDR_FLAG_STR_CONFORMANT; + + if (flags & LIBNDR_FLAG_STR_CHARLEN) { + c_len_term = 0; + flags &= ~LIBNDR_FLAG_STR_CHARLEN; + } + switch (flags & LIBNDR_STRING_FLAGS) { case LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4: - NDR_CHECK(ndr_push_uint32(ndr, c_len+1)); + NDR_CHECK(ndr_push_uint32(ndr, c_len+c_len_term)); NDR_CHECK(ndr_push_uint32(ndr, 0)); - NDR_CHECK(ndr_push_uint32(ndr, c_len+1)); + NDR_CHECK(ndr_push_uint32(ndr, c_len+c_len_term)); NDR_PUSH_NEED_BYTES(ndr, byte_mul*(c_len+1)); ret = convert_string(CH_UNIX, chset, s, s_len+1, @@ -792,7 +803,7 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) case LIBNDR_FLAG_STR_LEN4: NDR_CHECK(ndr_push_uint32(ndr, 0)); - NDR_CHECK(ndr_push_uint32(ndr, c_len + 1)); + NDR_CHECK(ndr_push_uint32(ndr, c_len + c_len_term)); NDR_PUSH_NEED_BYTES(ndr, byte_mul*(c_len+1)); ret = convert_string(CH_UNIX, chset, s, s_len + 1, @@ -805,7 +816,7 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) break; case LIBNDR_FLAG_STR_SIZE4: - NDR_CHECK(ndr_push_uint32(ndr, c_len + 1)); + NDR_CHECK(ndr_push_uint32(ndr, c_len + c_len_term)); NDR_PUSH_NEED_BYTES(ndr, byte_mul*(c_len+1)); ret = convert_string(CH_UNIX, chset, s, s_len + 1, @@ -818,7 +829,7 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) break; case LIBNDR_FLAG_STR_SIZE2: - NDR_CHECK(ndr_push_uint16(ndr, c_len + 1)); + NDR_CHECK(ndr_push_uint16(ndr, c_len + c_len_term)); NDR_PUSH_NEED_BYTES(ndr, byte_mul*(c_len+1)); ret = convert_string(CH_UNIX, chset, s, s_len + 1, @@ -875,6 +886,40 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) return NT_STATUS_OK; } +/* + push a general string onto the wire +*/ +size_t ndr_string_array_size(struct ndr_push *ndr, const char *s) +{ + size_t c_len; + unsigned flags = ndr->flags; + unsigned byte_mul = 2; + unsigned c_len_term = 1; + + if (flags & LIBNDR_FLAG_STR_FIXLEN32) { + return 32; + } + + c_len = s?strlen_m(s):0; + + if (flags & LIBNDR_FLAG_STR_ASCII) { + byte_mul = 1; + } + + if (flags & LIBNDR_FLAG_STR_NOTERM) { + c_len_term = 0; + } + + c_len = c_len + c_len_term; + + if (flags & LIBNDR_FLAG_STR_BYTESIZE) { + c_len = c_len * byte_mul; + } + + return c_len; +} + + /* push a NTTIME */ -- cgit From e0e6e0f99d9c7645e1809a3bde1a6ab01843de67 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 3 Nov 2004 16:02:32 +0000 Subject: r3512: - support DsCrackName GUID strings ('{faedf4f9-0de8-4582-b8b6-c475efefbe5a}') - resolve the GUID's we got in DsGetDomainControllerInfo in the DsCrackNames test metze (This used to be commit f6310695821a7e750dd37936a6145232d81ab413) --- source4/librpc/ndr/ndr_basic.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 84c4ab9ddc..2dc28c3783 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -1148,19 +1148,29 @@ void ndr_print_array_uint8(struct ndr_print *ndr, const char *name, */ NTSTATUS GUID_from_string(const char *s, struct GUID *guid) { + NTSTATUS status = NT_STATUS_INVALID_PARAMETER; uint32_t time_low; uint32_t time_mid, time_hi_and_version; uint32_t clock_seq[2]; uint32_t node[6]; int i; - if (11 != sscanf(s, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + if (11 == sscanf(s, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", &time_low, &time_mid, &time_hi_and_version, &clock_seq[0], &clock_seq[1], &node[0], &node[1], &node[2], &node[3], &node[4], &node[5])) { - return NT_STATUS_INVALID_PARAMETER; + status = NT_STATUS_OK; + } else if (11 == sscanf(s, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", + &time_low, &time_mid, &time_hi_and_version, + &clock_seq[0], &clock_seq[1], + &node[0], &node[1], &node[2], &node[3], &node[4], &node[5])) { + status = NT_STATUS_OK; } + if (!NT_STATUS_IS_OK(status)) { + return status; + } + guid->time_low = time_low; guid->time_mid = time_mid; guid->time_hi_and_version = time_hi_and_version; @@ -1189,6 +1199,19 @@ const char *GUID_string(TALLOC_CTX *mem_ctx, const struct GUID *guid) guid->node[4], guid->node[5]); } +const char *GUID_string2(TALLOC_CTX *mem_ctx, const struct GUID *guid) +{ + return talloc_asprintf(mem_ctx, + "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", + guid->time_low, guid->time_mid, + guid->time_hi_and_version, + guid->clock_seq[0], + guid->clock_seq[1], + guid->node[0], guid->node[1], + guid->node[2], guid->node[3], + guid->node[4], guid->node[5]); +} + void ndr_print_GUID(struct ndr_print *ndr, const char *name, const struct GUID *guid) { ndr->print(ndr, "%-25s: %s", name, GUID_string(ndr, guid)); -- cgit From 12f4a44cf549b4ccd729494c242a5ec186d2d670 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 5 Nov 2004 11:31:35 +0000 Subject: r3549: added support for DOS extended attribute lists (name/value pairs) stored in posix xattrs (This used to be commit bad6a88371264cffce2bf5d6ce904b7b357081de) --- source4/librpc/ndr/ndr_basic.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 2dc28c3783..ed591a2e5e 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -522,6 +522,12 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) flags &= ~LIBNDR_FLAG_STR_ASCII; } + if (flags & LIBNDR_FLAG_STR_UTF8) { + chset = CH_UTF8; + byte_mul = 1; + flags &= ~LIBNDR_FLAG_STR_UTF8; + } + flags &= ~LIBNDR_FLAG_STR_CONFORMANT; flags &= ~LIBNDR_FLAG_STR_CHARLEN; @@ -762,6 +768,12 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) flags &= ~LIBNDR_FLAG_STR_ASCII; } + if (flags & LIBNDR_FLAG_STR_UTF8) { + chset = CH_UTF8; + byte_mul = 1; + flags &= ~LIBNDR_FLAG_STR_UTF8; + } + flags &= ~LIBNDR_FLAG_STR_CONFORMANT; if (flags & LIBNDR_FLAG_STR_CHARLEN) { @@ -902,7 +914,7 @@ size_t ndr_string_array_size(struct ndr_push *ndr, const char *s) c_len = s?strlen_m(s):0; - if (flags & LIBNDR_FLAG_STR_ASCII) { + if (flags & (LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_UTF8)) { byte_mul = 1; } -- cgit From eee5cc3b9a6fe7cdc1fa81fac8ce524391bee519 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 6 Nov 2004 20:08:05 +0000 Subject: r3582: more gcc-4.0 signedness fixes metze (This used to be commit 07405f1c67e9df8a972e17f5bdaf312977960474) --- source4/librpc/ndr/ndr_basic.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index ed591a2e5e..1bccead269 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -198,7 +198,7 @@ void ndr_print_WERROR(struct ndr_print *ndr, const char *name, WERROR r) /* parse a set of bytes */ -NTSTATUS ndr_pull_bytes(struct ndr_pull *ndr, char *data, uint32_t n) +NTSTATUS ndr_pull_bytes(struct ndr_pull *ndr, uint8_t *data, uint32_t n) { NDR_PULL_NEED_BYTES(ndr, n); memcpy(data, ndr->data + ndr->offset, n); @@ -209,7 +209,7 @@ NTSTATUS ndr_pull_bytes(struct ndr_pull *ndr, char *data, uint32_t n) /* pull an array of uint8 */ -NTSTATUS ndr_pull_array_uint8(struct ndr_pull *ndr, int ndr_flags, char *data, uint32_t n) +NTSTATUS ndr_pull_array_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *data, uint32_t n) { if (!(ndr_flags & NDR_SCALARS)) { return NT_STATUS_OK; @@ -372,7 +372,7 @@ NTSTATUS ndr_pull_align(struct ndr_pull *ndr, size_t size) /* push some bytes */ -NTSTATUS ndr_push_bytes(struct ndr_push *ndr, const char *data, uint32_t n) +NTSTATUS ndr_push_bytes(struct ndr_push *ndr, const uint8_t *data, uint32_t n) { NDR_PUSH_NEED_BYTES(ndr, n); memcpy(ndr->data + ndr->offset, data, n); @@ -394,7 +394,7 @@ NTSTATUS ndr_push_zero(struct ndr_push *ndr, uint32_t n) /* push an array of uint8 */ -NTSTATUS ndr_push_array_uint8(struct ndr_push *ndr, int ndr_flags, const char *data, uint32_t n) +NTSTATUS ndr_push_array_uint8(struct ndr_push *ndr, int ndr_flags, const uint8_t *data, uint32_t n) { if (!(ndr_flags & NDR_SCALARS)) { return NT_STATUS_OK; @@ -698,7 +698,7 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) case LIBNDR_FLAG_STR_NULLTERM: if (byte_mul == 1) { - len1 = ascii_len_n(ndr->data+ndr->offset, ndr->data_size - ndr->offset); + len1 = ascii_len_n((const char *)(ndr->data+ndr->offset), ndr->data_size - ndr->offset); } else { len1 = utf16_len_n(ndr->data+ndr->offset, ndr->data_size - ndr->offset); } -- cgit From 536601aeba8adb3fe3ac4af19088910c31959f93 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 16 Nov 2004 11:17:59 +0000 Subject: r3785: this strings are not const metze (This used to be commit 436da375a2a815926aaa0565120a4750ead37cb0) --- source4/librpc/ndr/ndr_basic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 1bccead269..70fd0b34a4 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -1198,7 +1198,7 @@ NTSTATUS GUID_from_string(const char *s, struct GUID *guid) /* its useful to be able to display these in debugging messages */ -const char *GUID_string(TALLOC_CTX *mem_ctx, const struct GUID *guid) +char *GUID_string(TALLOC_CTX *mem_ctx, const struct GUID *guid) { return talloc_asprintf(mem_ctx, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", @@ -1211,7 +1211,7 @@ const char *GUID_string(TALLOC_CTX *mem_ctx, const struct GUID *guid) guid->node[4], guid->node[5]); } -const char *GUID_string2(TALLOC_CTX *mem_ctx, const struct GUID *guid) +char *GUID_string2(TALLOC_CTX *mem_ctx, const struct GUID *guid) { return talloc_asprintf(mem_ctx, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", -- cgit From c3eb37f292cd0b31063d25f0f0cc3dfe53b320e5 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 16 Nov 2004 13:14:02 +0000 Subject: r3787: a function to generate a random GUID metze (This used to be commit 8bd2e3cb4e5123a3e26965b8535e16ee18005714) --- source4/librpc/ndr/ndr_basic.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 70fd0b34a4..9507f4d33b 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -1195,6 +1195,16 @@ NTSTATUS GUID_from_string(const char *s, struct GUID *guid) return NT_STATUS_OK; } +/* generate a random GUID */ +struct GUID GUID_random(void) +{ + struct GUID guid; + + generate_random_buffer((uint8_t *)&guid, sizeof(guid)); + + return guid; +} + /* its useful to be able to display these in debugging messages */ -- cgit From a0fa682faa309bda812008ea3a084cf54f65310b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 18 Nov 2004 20:53:23 +0000 Subject: r3861: - Put ndr and rpc client code in seperate files - Add some const (This used to be commit a00bda88e1b6abdc36e5aa8c2a35f64855f67c96) --- source4/librpc/ndr/ndr_basic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 9507f4d33b..057b162ca9 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -1304,7 +1304,7 @@ uint32 ndr_size_DATA_BLOB(int ret, const DATA_BLOB *data, int flags) return ret + data->length; } -uint32 ndr_size_string(int ret, const char **string, int flags) +uint32 ndr_size_string(int ret, const char * const* string, int flags) { /* FIXME: Is this correct for all strings ? */ if(!(*string)) return ret; -- cgit From 717c8bc7950c2f0eabcdbc7437f47289f6b227b5 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 19 Nov 2004 02:35:48 +0000 Subject: r3869: in the NDR encoded replPropertyMetaData attribute in ADS I see a new 64 bit time field which are seconds since 1601, this will be mapped to NTTIME by th eparsing code +#define NTTIME_1sec NTTIME metze (This used to be commit db35f3b0f99943311ff8b797e8336616dab28220) --- source4/librpc/ndr/ndr_basic.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 057b162ca9..f26c40e7b7 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -950,6 +950,26 @@ NTSTATUS ndr_pull_NTTIME(struct ndr_pull *ndr, NTTIME *t) return NT_STATUS_OK; } +/* + push a NTTIME +*/ +NTSTATUS ndr_push_NTTIME_1sec(struct ndr_push *ndr, NTTIME t) +{ + t /= 10000000; + NDR_CHECK(ndr_push_uint64(ndr, t)); + return NT_STATUS_OK; +} + +/* + pull a NTTIME +*/ +NTSTATUS ndr_pull_NTTIME_1sec(struct ndr_pull *ndr, NTTIME *t) +{ + NDR_CHECK(ndr_pull_uint64(ndr, t)); + (*t) *= 10000000; + return NT_STATUS_OK; +} + /* push a time_t */ @@ -997,7 +1017,10 @@ void ndr_print_int32(struct ndr_print *ndr, const char *name, int32_t v) void ndr_print_uint64(struct ndr_print *ndr, const char *name, uint64_t v) { - ndr->print(ndr, "%-25s: 0x%08x%08x", name, (uint32_t)(v >> 32), (uint32_t)(v & 0xFFFFFFFF)); + ndr->print(ndr, "%-25s: 0x%08x%08x (%llu)", name, + (uint32_t)(v >> 32), + (uint32_t)(v & 0xFFFFFFFF), + v); } void ndr_print_int64(struct ndr_print *ndr, const char *name, int64_t v) @@ -1036,6 +1059,11 @@ void ndr_print_NTTIME(struct ndr_print *ndr, const char *name, NTTIME t) ndr->print(ndr, "%-25s: %s", name, nt_time_string(ndr, t)); } +void ndr_print_NTTIME_1sec(struct ndr_print *ndr, const char *name, NTTIME t) +{ + ndr_print_NTTIME(ndr, name, t); +} + void ndr_print_time_t(struct ndr_print *ndr, const char *name, time_t t) { if (t == (time_t)-1 || t == 0) { -- cgit From e90061865467600a9d8a34f92e60a296cbf19234 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 25 Nov 2004 20:03:46 +0000 Subject: r3972: use GUID_* naming context and move GUID_* functions to one place metze (This used to be commit 523e6acf4fec5d4946fa7c0c89f40d7d712c9f3a) --- source4/librpc/ndr/ndr_basic.c | 84 ------------------------------------------ 1 file changed, 84 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index f26c40e7b7..b790b03aa9 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -1183,90 +1183,6 @@ void ndr_print_array_uint8(struct ndr_print *ndr, const char *name, ndr->depth--; } -/* - build a GUID from a string -*/ -NTSTATUS GUID_from_string(const char *s, struct GUID *guid) -{ - NTSTATUS status = NT_STATUS_INVALID_PARAMETER; - uint32_t time_low; - uint32_t time_mid, time_hi_and_version; - uint32_t clock_seq[2]; - uint32_t node[6]; - int i; - - if (11 == sscanf(s, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", - &time_low, &time_mid, &time_hi_and_version, - &clock_seq[0], &clock_seq[1], - &node[0], &node[1], &node[2], &node[3], &node[4], &node[5])) { - status = NT_STATUS_OK; - } else if (11 == sscanf(s, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", - &time_low, &time_mid, &time_hi_and_version, - &clock_seq[0], &clock_seq[1], - &node[0], &node[1], &node[2], &node[3], &node[4], &node[5])) { - status = NT_STATUS_OK; - } - - if (!NT_STATUS_IS_OK(status)) { - return status; - } - - guid->time_low = time_low; - guid->time_mid = time_mid; - guid->time_hi_and_version = time_hi_and_version; - guid->clock_seq[0] = clock_seq[0]; - guid->clock_seq[1] = clock_seq[1]; - for (i=0;i<6;i++) { - guid->node[i] = node[i]; - } - - return NT_STATUS_OK; -} - -/* generate a random GUID */ -struct GUID GUID_random(void) -{ - struct GUID guid; - - generate_random_buffer((uint8_t *)&guid, sizeof(guid)); - - return guid; -} - -/* - its useful to be able to display these in debugging messages -*/ -char *GUID_string(TALLOC_CTX *mem_ctx, const struct GUID *guid) -{ - return talloc_asprintf(mem_ctx, - "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", - guid->time_low, guid->time_mid, - guid->time_hi_and_version, - guid->clock_seq[0], - guid->clock_seq[1], - guid->node[0], guid->node[1], - guid->node[2], guid->node[3], - guid->node[4], guid->node[5]); -} - -char *GUID_string2(TALLOC_CTX *mem_ctx, const struct GUID *guid) -{ - return talloc_asprintf(mem_ctx, - "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", - guid->time_low, guid->time_mid, - guid->time_hi_and_version, - guid->clock_seq[0], - guid->clock_seq[1], - guid->node[0], guid->node[1], - guid->node[2], guid->node[3], - guid->node[4], guid->node[5]); -} - -void ndr_print_GUID(struct ndr_print *ndr, const char *name, const struct GUID *guid) -{ - ndr->print(ndr, "%-25s: %s", name, GUID_string(ndr, guid)); -} - void ndr_print_DATA_BLOB(struct ndr_print *ndr, const char *name, DATA_BLOB r) { ndr->print(ndr, "%-25s: DATA_BLOB length=%u", name, r.length); -- cgit From 3558d8b40dd2b24a74192bc5fba5312104efe7cd Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 29 Nov 2004 11:04:36 +0000 Subject: r3997: fix STR_CHARLEN pull case metze (This used to be commit 623411f74ee766dee2170949b118216387779929) --- source4/librpc/ndr/ndr_basic.c | 46 +++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 21 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index b790b03aa9..3959e91563 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -507,6 +507,7 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) int chset = CH_UTF16; unsigned byte_mul = 2; unsigned flags = ndr->flags; + unsigned c_len_term = 0; if (!(ndr_flags & NDR_SCALARS)) { return NT_STATUS_OK; @@ -529,7 +530,10 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) } flags &= ~LIBNDR_FLAG_STR_CONFORMANT; - flags &= ~LIBNDR_FLAG_STR_CHARLEN; + if (flags & LIBNDR_FLAG_STR_CHARLEN) { + c_len_term = 1; + flags &= ~LIBNDR_FLAG_STR_CHARLEN; + } switch (flags & LIBNDR_STRING_FLAGS) { case LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4: @@ -550,25 +554,25 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) *s = talloc_strdup(ndr, ""); break; } - NDR_PULL_NEED_BYTES(ndr, len2*byte_mul); + NDR_PULL_NEED_BYTES(ndr, (len2 + c_len_term)*byte_mul); ret = convert_string_talloc(ndr, chset, CH_UNIX, ndr->data+ndr->offset, - len2*byte_mul, + (len2 + c_len_term)*byte_mul, (void **)&as); if (ret == -1) { return ndr_pull_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); } - NDR_CHECK(ndr_pull_advance(ndr, len2*byte_mul)); + NDR_CHECK(ndr_pull_advance(ndr, (len2 + c_len_term)*byte_mul)); /* this is a way of detecting if a string is sent with the wrong termination */ if (ndr->flags & LIBNDR_FLAG_STR_NOTERM) { - if (strlen(as) < len2) { + if (strlen(as) < (len2 + c_len_term)) { DEBUG(6,("short string '%s'\n", as)); } } else { - if (strlen(as) == len2) { + if (strlen(as) == (len2 + c_len_term)) { DEBUG(6,("long string '%s'\n", as)); } } @@ -578,29 +582,29 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) case LIBNDR_FLAG_STR_SIZE4: case LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_NOTERM: NDR_CHECK(ndr_pull_uint32(ndr, &len1)); - NDR_PULL_NEED_BYTES(ndr, len1*byte_mul); + NDR_PULL_NEED_BYTES(ndr, (len1 + c_len_term)*byte_mul); if (len1 == 0) { *s = talloc_strdup(ndr, ""); break; } ret = convert_string_talloc(ndr, chset, CH_UNIX, ndr->data+ndr->offset, - len1*byte_mul, + (len1 + c_len_term)*byte_mul, (void **)&as); if (ret == -1) { return ndr_pull_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); } - NDR_CHECK(ndr_pull_advance(ndr, len1*byte_mul)); + NDR_CHECK(ndr_pull_advance(ndr, (len1 + c_len_term)*byte_mul)); /* this is a way of detecting if a string is sent with the wrong termination */ if (ndr->flags & LIBNDR_FLAG_STR_NOTERM) { - if (strlen(as) < len1) { + if (strlen(as) < (len1 + c_len_term)) { DEBUG(6,("short string '%s'\n", as)); } } else { - if (strlen(as) == len1) { + if (strlen(as) == (len1 + c_len_term)) { DEBUG(6,("long string '%s'\n", as)); } } @@ -615,29 +619,29 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) ndr->flags & LIBNDR_STRING_FLAGS); } NDR_CHECK(ndr_pull_uint32(ndr, &len1)); - NDR_PULL_NEED_BYTES(ndr, len1*byte_mul); + NDR_PULL_NEED_BYTES(ndr, (len1 + c_len_term)*byte_mul); if (len1 == 0) { *s = talloc_strdup(ndr, ""); break; } ret = convert_string_talloc(ndr, chset, CH_UNIX, ndr->data+ndr->offset, - len1*byte_mul, + (len1 + c_len_term)*byte_mul, (void **)&as); if (ret == -1) { return ndr_pull_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); } - NDR_CHECK(ndr_pull_advance(ndr, len1*byte_mul)); + NDR_CHECK(ndr_pull_advance(ndr, (len1 + c_len_term)*byte_mul)); /* this is a way of detecting if a string is sent with the wrong termination */ if (ndr->flags & LIBNDR_FLAG_STR_NOTERM) { - if (strlen(as) < len1) { + if (strlen(as) < (len1 + c_len_term)) { DEBUG(6,("short string '%s'\n", as)); } } else { - if (strlen(as) == len1) { + if (strlen(as) == (len1 + c_len_term)) { DEBUG(6,("long string '%s'\n", as)); } } @@ -648,29 +652,29 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) case LIBNDR_FLAG_STR_SIZE2: case LIBNDR_FLAG_STR_SIZE2|LIBNDR_FLAG_STR_NOTERM: NDR_CHECK(ndr_pull_uint16(ndr, &len3)); - NDR_PULL_NEED_BYTES(ndr, len3*byte_mul); + NDR_PULL_NEED_BYTES(ndr, (len3 + c_len_term)*byte_mul); if (len3 == 0) { *s = talloc_strdup(ndr, ""); break; } ret = convert_string_talloc(ndr, chset, CH_UNIX, ndr->data+ndr->offset, - len3*byte_mul, + (len3 + c_len_term)*byte_mul, (void **)&as); if (ret == -1) { return ndr_pull_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); } - NDR_CHECK(ndr_pull_advance(ndr, len3*byte_mul)); + NDR_CHECK(ndr_pull_advance(ndr, (len3 + c_len_term)*byte_mul)); /* this is a way of detecting if a string is sent with the wrong termination */ if (ndr->flags & LIBNDR_FLAG_STR_NOTERM) { - if (strlen(as) < len3) { + if (strlen(as) < (len3 + c_len_term)) { DEBUG(6,("short string '%s'\n", as)); } } else { - if (strlen(as) == len3) { + if (strlen(as) == (len3 + c_len_term)) { DEBUG(6,("long string '%s'\n", as)); } } -- cgit From 87d5e061e0ddd41e21a60b8934db339e5ef5f306 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 8 Dec 2004 11:30:26 +0000 Subject: r4102: more uint64 vs HYPER_T fixes NOTE: [u]int64 uses 4 Byte alignment and HYPER_T uses 8 Byte alignment metze (This used to be commit 717454eb2fd2bf90e67074acefdae5304cd7433f) --- source4/librpc/ndr/ndr_basic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 3959e91563..315dc76059 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -960,7 +960,7 @@ NTSTATUS ndr_pull_NTTIME(struct ndr_pull *ndr, NTTIME *t) NTSTATUS ndr_push_NTTIME_1sec(struct ndr_push *ndr, NTTIME t) { t /= 10000000; - NDR_CHECK(ndr_push_uint64(ndr, t)); + NDR_CHECK(ndr_push_HYPER_T(ndr, t)); return NT_STATUS_OK; } @@ -969,7 +969,7 @@ NTSTATUS ndr_push_NTTIME_1sec(struct ndr_push *ndr, NTTIME t) */ NTSTATUS ndr_pull_NTTIME_1sec(struct ndr_pull *ndr, NTTIME *t) { - NDR_CHECK(ndr_pull_uint64(ndr, t)); + NDR_CHECK(ndr_pull_HYPER_T(ndr, t)); (*t) *= 10000000; return NT_STATUS_OK; } -- cgit From 8448dd6ea0c706e0d5ec5d8773939aa188b62904 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 4 Jan 2005 23:26:12 +0000 Subject: r4519: added the enum print function in ndr_basic.c (This used to be commit 29955004aa256d5ac27b941f48384ab97ff5e4b8) --- source4/librpc/ndr/ndr_basic.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 315dc76059..8874984f4b 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -999,6 +999,12 @@ void ndr_print_struct(struct ndr_print *ndr, const char *name, const char *type) ndr->print(ndr, "%s: struct %s", name, type); } +void ndr_print_enum(struct ndr_print *ndr, const char *name, const char *type, + const char *val, uint32_t value) +{ + ndr->print(ndr, "%-25s: %s (%u)", name, val?val:"UNKNOWN", value); +} + void ndr_print_uint8(struct ndr_print *ndr, const char *name, uint8_t v) { ndr->print(ndr, "%-25s: 0x%02x (%u)", name, v, v); -- cgit From d0da601ff78c1df7422e3a558db5a4c4862eb785 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 5 Jan 2005 15:36:26 +0000 Subject: r4535: add full support for typedef bitmap { FLAG1 = 0x01 } fooflags; typedef struct { fooflags flags; } metze (This used to be commit 052a7d4f9a3a178149c65a616fdfd87152dff7eb) --- source4/librpc/ndr/ndr_basic.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 8874984f4b..8c9664771d 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -1000,9 +1000,18 @@ void ndr_print_struct(struct ndr_print *ndr, const char *name, const char *type) } void ndr_print_enum(struct ndr_print *ndr, const char *name, const char *type, - const char *val, uint32_t value) + const char *val, uint_t value) { - ndr->print(ndr, "%-25s: %s (%u)", name, val?val:"UNKNOWN", value); + ndr->print(ndr, "%-25s: %s (%d)", name, val?val:"UNKNOWN_ENUM_VALUE", value); +} + +void ndr_print_bitmap_flag(struct ndr_print *ndr, size_t size, const char *flag_name, uint_t flag, uint_t value) +{ + /* size can be later used to print something like: + * ...1.... .........: FLAG1_NAME + * .....0.. .........: FLAG2_NAME + */ + ndr->print(ndr, "%s: %-25s", (flag & value)?"1":"0", flag_name); } void ndr_print_uint8(struct ndr_print *ndr, const char *name, uint8_t v) -- cgit From 66af8726e525d6978936d5e950b0e4c3af66c86c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 6 Jan 2005 07:29:55 +0000 Subject: r4557: support for [flags()] on typedef enum|bitmap NDR_PAHEX is handled by ndr_print_enum() now metze (This used to be commit c3b2d2cca37193fead0df1a8808c3ffcd5180a89) --- source4/librpc/ndr/ndr_basic.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 8c9664771d..13ac087978 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -1002,7 +1002,11 @@ void ndr_print_struct(struct ndr_print *ndr, const char *name, const char *type) void ndr_print_enum(struct ndr_print *ndr, const char *name, const char *type, const char *val, uint_t value) { - ndr->print(ndr, "%-25s: %s (%d)", name, val?val:"UNKNOWN_ENUM_VALUE", value); + if (ndr->flags & LIBNDR_PRINT_ARRAY_HEX) { + ndr->print(ndr, "%-25s: %s (0x%X)", name, val?val:"UNKNOWN_ENUM_VALUE", value); + } else { + ndr->print(ndr, "%-25s: %s (%d)", name, val?val:"UNKNOWN_ENUM_VALUE", value); + } } void ndr_print_bitmap_flag(struct ndr_print *ndr, size_t size, const char *flag_name, uint_t flag, uint_t value) -- cgit From 462ef44745d56dbb00b3e31d12d2ecdc9d309219 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 11 Jan 2005 05:16:43 +0000 Subject: r4673: Fix the IDL for the QuerySecret LSA call. This call uses a new IDL type, NTTIME_hyper. This is 8-byte aligned, as the name suggests. Expand the QuerySecret LSA calls in RPC-SAMLOGON and RPC-LSA, to validate the behaviour of times, and of the old secrets. Thanks to tridge for spotting the use of HYPER! Andrew Bartlett (This used to be commit 1fed79cb0f2ae7940639d08ef99576559d4cd06e) --- source4/librpc/ndr/ndr_basic.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 13ac087978..689483986e 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -965,7 +965,7 @@ NTSTATUS ndr_push_NTTIME_1sec(struct ndr_push *ndr, NTTIME t) } /* - pull a NTTIME + pull a NTTIME_1sec */ NTSTATUS ndr_pull_NTTIME_1sec(struct ndr_pull *ndr, NTTIME *t) { @@ -974,6 +974,24 @@ NTSTATUS ndr_pull_NTTIME_1sec(struct ndr_pull *ndr, NTTIME *t) return NT_STATUS_OK; } +/* + pull a NTTIME_hyper +*/ +NTSTATUS ndr_pull_NTTIME_hyper(struct ndr_pull *ndr, NTTIME_hyper *t) +{ + NDR_CHECK(ndr_pull_HYPER_T(ndr, t)); + return NT_STATUS_OK; +} + +/* + push a NTTIME_hyper +*/ +NTSTATUS ndr_push_NTTIME_hyper(struct ndr_push *ndr, NTTIME_hyper t) +{ + NDR_CHECK(ndr_push_HYPER_T(ndr, t)); + return NT_STATUS_OK; +} + /* push a time_t */ @@ -1082,7 +1100,12 @@ void ndr_print_NTTIME(struct ndr_print *ndr, const char *name, NTTIME t) ndr->print(ndr, "%-25s: %s", name, nt_time_string(ndr, t)); } -void ndr_print_NTTIME_1sec(struct ndr_print *ndr, const char *name, NTTIME t) +void ndr_print_NTTIME_1sec(struct ndr_print *ndr, const char *name, NTTIME_1sec t) +{ + ndr_print_NTTIME(ndr, name, t * 10000000); +} + +void ndr_print_NTTIME_hyper(struct ndr_print *ndr, const char *name, NTTIME_hyper t) { ndr_print_NTTIME(ndr, name, t); } -- cgit From 945180f6763f713d9e56a836fae980d39c26a267 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 11 Jan 2005 06:47:15 +0000 Subject: r4676: NTTIME_1sec is a standard NTTIME for the calling code as it's already converted in the pull/push code metze (This used to be commit 0d2286ba56fa8d25244a5554e75b5be24eba28b0) --- source4/librpc/ndr/ndr_basic.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 689483986e..29a3009af6 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -1102,7 +1102,10 @@ void ndr_print_NTTIME(struct ndr_print *ndr, const char *name, NTTIME t) void ndr_print_NTTIME_1sec(struct ndr_print *ndr, const char *name, NTTIME_1sec t) { - ndr_print_NTTIME(ndr, name, t * 10000000); + /* this is a standard NTTIME here + * as it's already converted in the pull/push code + */ + ndr_print_NTTIME(ndr, name, t); } void ndr_print_NTTIME_hyper(struct ndr_print *ndr, const char *name, NTTIME_hyper t) -- cgit From ea923fb4a26f88664a1db36e1a93a2c96239a7a4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 21 Jan 2005 06:54:10 +0000 Subject: r4885: added a new NBT client library. Features include: - structures defined using IDL in nbt.idl - build around our events structure, and talloc - fully async - supports all NBT packet fields as per rfc1002 - easy interfaces for name query and status For the moment there are just a couple of test functions in namequery.c, test_name_query() and test_name_status(). These will be removed when we hook the new library into libcli/ fully The new library will also be a fairly good basis for a nbt server. Although it can't be a server as-is, I wrote it with the needs of a server in mind (for example, extremely scalable idtree based packet handling) (This used to be commit ae7e625bfa4b4a3ee32c64566064b6a4c84ee4b9) --- source4/librpc/ndr/ndr_basic.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 29a3009af6..6476f58764 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -718,8 +718,9 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) *s = as; break; + case LIBNDR_FLAG_STR_FIXLEN15: case LIBNDR_FLAG_STR_FIXLEN32: - len1 = 32; + len1 = (flags & LIBNDR_FLAG_STR_FIXLEN32)?32:15; NDR_PULL_NEED_BYTES(ndr, len1*byte_mul); ret = convert_string_talloc(ndr, chset, CH_UNIX, ndr->data+ndr->offset, @@ -733,7 +734,6 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) *s = as; break; - default: return ndr_pull_error(ndr, NDR_ERR_STRING, "Bad string flags 0x%x\n", ndr->flags & LIBNDR_STRING_FLAGS); @@ -748,7 +748,7 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) */ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) { - ssize_t s_len, c_len; + ssize_t s_len, c_len, d_len; int ret; int chset = CH_UTF16; unsigned flags = ndr->flags; @@ -882,16 +882,18 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) ndr->offset += c_len*byte_mul; break; + case LIBNDR_FLAG_STR_FIXLEN15: case LIBNDR_FLAG_STR_FIXLEN32: - NDR_PUSH_NEED_BYTES(ndr, byte_mul*32); + d_len = (flags & LIBNDR_FLAG_STR_FIXLEN32)?32:15; + NDR_PUSH_NEED_BYTES(ndr, byte_mul*d_len); ret = convert_string(CH_UNIX, chset, s, s_len + 1, - ndr->data+ndr->offset, byte_mul*32); + ndr->data+ndr->offset, byte_mul*d_len); if (ret == -1) { return ndr_push_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); } - ndr->offset += byte_mul*32; + ndr->offset += byte_mul*d_len; break; default: @@ -915,6 +917,9 @@ size_t ndr_string_array_size(struct ndr_push *ndr, const char *s) if (flags & LIBNDR_FLAG_STR_FIXLEN32) { return 32; } + if (flags & LIBNDR_FLAG_STR_FIXLEN15) { + return 15; + } c_len = s?strlen_m(s):0; @@ -1029,11 +1034,18 @@ void ndr_print_enum(struct ndr_print *ndr, const char *name, const char *type, void ndr_print_bitmap_flag(struct ndr_print *ndr, size_t size, const char *flag_name, uint_t flag, uint_t value) { - /* size can be later used to print something like: - * ...1.... .........: FLAG1_NAME - * .....0.. .........: FLAG2_NAME - */ - ndr->print(ndr, "%s: %-25s", (flag & value)?"1":"0", flag_name); + /* this is an attempt to support multi-bit bitmap masks */ + value &= flag; + + while (!(flag & 1)) { + flag >>= 1; + value >>= 1; + } + if (flag == 1) { + ndr->print(ndr, " %d: %-25s", value, flag_name); + } else { + ndr->print(ndr, "0x%02x: %-25s (%d)", value, flag_name, value); + } } void ndr_print_uint8(struct ndr_print *ndr, const char *name, uint8_t v) -- cgit From 3dd17f128831e09c230a8d56e34495d3b31dbacb Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 27 Jan 2005 06:16:59 +0000 Subject: r5034: - added a type mapping function in pidl, so the type names in our IDL files don't need to match the type names in the generated headers - with this type mapping we no longer need definitions for the deprecated "int32", "uint8" etc form of types. We can now force everyone to use the standard types int32_t, uint8_t etc. - fixed all the code that used the deprecated types - converted the IDL types "int64" and "uint64" to "dlong" and "udlong". These are the 4 byte aligned 64 bit integers that Microsoft internally define as two 32 bit integers in a structure. After discussions with Ronnie Sahlberg we decided that calling these "int64" was confusing, as it implied a true 8 byte aligned type - fixed all the cases where we incorrectly used things like "NTTIME_hyper" in our C code. The generated API now uses a NTTIME for those. The fact that it is hyper-aligned on the wire is not relevant to the API, and should remain just a IDL property (This used to be commit f86521677d7ff16bdc4815f9524e5286026f10f3) --- source4/librpc/ndr/ndr_basic.c | 52 +++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 6476f58764..7ca930d78d 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -118,9 +118,9 @@ NTSTATUS ndr_pull_ptr(struct ndr_pull *ndr, uint32_t *v) } /* - parse a uint64 + parse a udlong */ -NTSTATUS ndr_pull_uint64(struct ndr_pull *ndr, uint64_t *v) +NTSTATUS ndr_pull_udlong(struct ndr_pull *ndr, uint64_t *v) { NDR_PULL_ALIGN(ndr, 4); NDR_PULL_NEED_BYTES(ndr, 8); @@ -131,20 +131,20 @@ NTSTATUS ndr_pull_uint64(struct ndr_pull *ndr, uint64_t *v) } /* - parse a int64 + parse a dlong */ -NTSTATUS ndr_pull_int64(struct ndr_pull *ndr, int64_t *v) +NTSTATUS ndr_pull_dlong(struct ndr_pull *ndr, int64_t *v) { - return ndr_pull_uint64(ndr, (uint64_t *)v); + return ndr_pull_udlong(ndr, (uint64_t *)v); } /* - parse a HYPER_T + parse a hyper */ -NTSTATUS ndr_pull_HYPER_T(struct ndr_pull *ndr, HYPER_T *v) +NTSTATUS ndr_pull_HYPER_T(struct ndr_pull *ndr, uint64_t *v) { NDR_PULL_ALIGN(ndr, 8); - return ndr_pull_uint64(ndr, v); + return ndr_pull_udlong(ndr, v); } /* @@ -251,7 +251,7 @@ NTSTATUS ndr_pull_array_uint32(struct ndr_pull *ndr, int ndr_flags, uint32_t *da /* pull a const array of HYPER_T */ -NTSTATUS ndr_pull_array_HYPER_T(struct ndr_pull *ndr, int ndr_flags, HYPER_T *data, uint32_t n) +NTSTATUS ndr_pull_array_HYPER_T(struct ndr_pull *ndr, int ndr_flags, uint64_t *data, uint32_t n) { uint32_t i; if (!(ndr_flags & NDR_SCALARS)) { @@ -330,7 +330,7 @@ NTSTATUS ndr_push_int32(struct ndr_push *ndr, int32_t v) /* push a uint64 */ -NTSTATUS ndr_push_uint64(struct ndr_push *ndr, uint64_t v) +NTSTATUS ndr_push_udlong(struct ndr_push *ndr, uint64_t v) { NDR_PUSH_ALIGN(ndr, 4); NDR_PUSH_NEED_BYTES(ndr, 8); @@ -343,18 +343,18 @@ NTSTATUS ndr_push_uint64(struct ndr_push *ndr, uint64_t v) /* push a int64 */ -NTSTATUS ndr_push_int64(struct ndr_push *ndr, int64_t v) +NTSTATUS ndr_push_dlong(struct ndr_push *ndr, int64_t v) { - return ndr_push_uint64(ndr, (uint64_t)v); + return ndr_push_udlong(ndr, (uint64_t)v); } /* push a HYPER_T */ -NTSTATUS ndr_push_HYPER_T(struct ndr_push *ndr, HYPER_T v) +NTSTATUS ndr_push_HYPER_T(struct ndr_push *ndr, uint64_t v) { NDR_PUSH_ALIGN(ndr, 8); - return ndr_push_uint64(ndr, v); + return ndr_push_udlong(ndr, v); } NTSTATUS ndr_push_align(struct ndr_push *ndr, size_t size) @@ -435,7 +435,7 @@ NTSTATUS ndr_push_array_uint32(struct ndr_push *ndr, int ndr_flags, const uint32 /* push an array of HYPER_T */ -NTSTATUS ndr_push_array_HYPER_T(struct ndr_push *ndr, int ndr_flags, const HYPER_T *data, uint32_t n) +NTSTATUS ndr_push_array_HYPER_T(struct ndr_push *ndr, int ndr_flags, const uint64_t *data, uint32_t n) { int i; if (!(ndr_flags & NDR_SCALARS)) { @@ -946,7 +946,7 @@ size_t ndr_string_array_size(struct ndr_push *ndr, const char *s) */ NTSTATUS ndr_push_NTTIME(struct ndr_push *ndr, NTTIME t) { - NDR_CHECK(ndr_push_uint64(ndr, t)); + NDR_CHECK(ndr_push_udlong(ndr, t)); return NT_STATUS_OK; } @@ -955,7 +955,7 @@ NTSTATUS ndr_push_NTTIME(struct ndr_push *ndr, NTTIME t) */ NTSTATUS ndr_pull_NTTIME(struct ndr_pull *ndr, NTTIME *t) { - NDR_CHECK(ndr_pull_uint64(ndr, t)); + NDR_CHECK(ndr_pull_udlong(ndr, t)); return NT_STATUS_OK; } @@ -982,7 +982,7 @@ NTSTATUS ndr_pull_NTTIME_1sec(struct ndr_pull *ndr, NTTIME *t) /* pull a NTTIME_hyper */ -NTSTATUS ndr_pull_NTTIME_hyper(struct ndr_pull *ndr, NTTIME_hyper *t) +NTSTATUS ndr_pull_NTTIME_hyper(struct ndr_pull *ndr, NTTIME *t) { NDR_CHECK(ndr_pull_HYPER_T(ndr, t)); return NT_STATUS_OK; @@ -991,7 +991,7 @@ NTSTATUS ndr_pull_NTTIME_hyper(struct ndr_pull *ndr, NTTIME_hyper *t) /* push a NTTIME_hyper */ -NTSTATUS ndr_push_NTTIME_hyper(struct ndr_push *ndr, NTTIME_hyper t) +NTSTATUS ndr_push_NTTIME_hyper(struct ndr_push *ndr, NTTIME t) { NDR_CHECK(ndr_push_HYPER_T(ndr, t)); return NT_STATUS_OK; @@ -1068,7 +1068,7 @@ void ndr_print_int32(struct ndr_print *ndr, const char *name, int32_t v) ndr->print(ndr, "%-25s: %d", name, v); } -void ndr_print_uint64(struct ndr_print *ndr, const char *name, uint64_t v) +void ndr_print_udlong(struct ndr_print *ndr, const char *name, uint64_t v) { ndr->print(ndr, "%-25s: 0x%08x%08x (%llu)", name, (uint32_t)(v >> 32), @@ -1076,7 +1076,7 @@ void ndr_print_uint64(struct ndr_print *ndr, const char *name, uint64_t v) v); } -void ndr_print_int64(struct ndr_print *ndr, const char *name, int64_t v) +void ndr_print_dlong(struct ndr_print *ndr, const char *name, int64_t v) { ndr->print(ndr, "%-25s: 0x%08x%08x (%lld)", name, (uint32_t)(v >> 32), @@ -1084,9 +1084,9 @@ void ndr_print_int64(struct ndr_print *ndr, const char *name, int64_t v) v); } -void ndr_print_HYPER_T(struct ndr_print *ndr, const char *name, HYPER_T v) +void ndr_print_HYPER_T(struct ndr_print *ndr, const char *name, uint64_t v) { - ndr->print(ndr, "%-25s: 0x%08x%08x", name, (uint32_t)(v >> 32), (uint32_t)(v & 0xFFFFFFFF)); + ndr_print_dlong(ndr, name, v); } void ndr_print_ptr(struct ndr_print *ndr, const char *name, const void *p) @@ -1112,7 +1112,7 @@ void ndr_print_NTTIME(struct ndr_print *ndr, const char *name, NTTIME t) ndr->print(ndr, "%-25s: %s", name, nt_time_string(ndr, t)); } -void ndr_print_NTTIME_1sec(struct ndr_print *ndr, const char *name, NTTIME_1sec t) +void ndr_print_NTTIME_1sec(struct ndr_print *ndr, const char *name, NTTIME t) { /* this is a standard NTTIME here * as it's already converted in the pull/push code @@ -1120,7 +1120,7 @@ void ndr_print_NTTIME_1sec(struct ndr_print *ndr, const char *name, NTTIME_1sec ndr_print_NTTIME(ndr, name, t); } -void ndr_print_NTTIME_hyper(struct ndr_print *ndr, const char *name, NTTIME_hyper t) +void ndr_print_NTTIME_hyper(struct ndr_print *ndr, const char *name, NTTIME t) { ndr_print_NTTIME(ndr, name, t); } @@ -1163,7 +1163,7 @@ void ndr_print_array_WERROR(struct ndr_print *ndr, const char *name, } void ndr_print_array_HYPER_T(struct ndr_print *ndr, const char *name, - const HYPER_T *data, uint32_t count) + const uint64_t *data, uint32_t count) { int i; -- cgit From 1e42cacf6a8643bd633f631c212d71760852abbc Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 27 Jan 2005 06:33:07 +0000 Subject: r5036: changed HYPER_T to the more standard "hyper" (This used to be commit 1d1a9c11ee681540ef8a1029409bb24fc26f976c) --- source4/librpc/ndr/ndr_basic.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 7ca930d78d..e38b9d394a 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -141,7 +141,7 @@ NTSTATUS ndr_pull_dlong(struct ndr_pull *ndr, int64_t *v) /* parse a hyper */ -NTSTATUS ndr_pull_HYPER_T(struct ndr_pull *ndr, uint64_t *v) +NTSTATUS ndr_pull_hyper(struct ndr_pull *ndr, uint64_t *v) { NDR_PULL_ALIGN(ndr, 8); return ndr_pull_udlong(ndr, v); @@ -249,16 +249,16 @@ NTSTATUS ndr_pull_array_uint32(struct ndr_pull *ndr, int ndr_flags, uint32_t *da } /* - pull a const array of HYPER_T + pull a const array of hyper */ -NTSTATUS ndr_pull_array_HYPER_T(struct ndr_pull *ndr, int ndr_flags, uint64_t *data, uint32_t n) +NTSTATUS ndr_pull_array_hyper(struct ndr_pull *ndr, int ndr_flags, uint64_t *data, uint32_t n) { uint32_t i; if (!(ndr_flags & NDR_SCALARS)) { return NT_STATUS_OK; } for (i=0;idepth--; } -void ndr_print_array_HYPER_T(struct ndr_print *ndr, const char *name, +void ndr_print_array_hyper(struct ndr_print *ndr, const char *name, const uint64_t *data, uint32_t count) { int i; @@ -1173,7 +1173,7 @@ void ndr_print_array_HYPER_T(struct ndr_print *ndr, const char *name, char *idx=NULL; asprintf(&idx, "[%d]", i); if (idx) { - ndr_print_HYPER_T(ndr, idx, data[i]); + ndr_print_hyper(ndr, idx, data[i]); free(idx); } } -- cgit From aa985bdee09e222f9f3f1f49e1cc20e0760c6f32 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 31 Jan 2005 04:15:58 +0000 Subject: r5118: added support for node status replies in nbtd. nmblookup -S now works against Samba4. Also added support for the '*' wildcard name (This used to be commit 2dd7ccf72444db668fa970c3a95de1448baea224) --- source4/librpc/ndr/ndr_basic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index e38b9d394a..61b3c9ec4d 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -887,7 +887,7 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) d_len = (flags & LIBNDR_FLAG_STR_FIXLEN32)?32:15; NDR_PUSH_NEED_BYTES(ndr, byte_mul*d_len); ret = convert_string(CH_UNIX, chset, - s, s_len + 1, + s, s_len, ndr->data+ndr->offset, byte_mul*d_len); if (ret == -1) { return ndr_push_error(ndr, NDR_ERR_CHARCNV, -- cgit From 4c6bcb0c05075b8fc606e72123b26288ea80d3bb Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 31 Jan 2005 16:10:36 +0000 Subject: r5139: fix types metze (This used to be commit 8507a57b88c6acce84d9ccc580e17c7f96c6d7af) --- source4/librpc/ndr/ndr_basic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 61b3c9ec4d..9601421044 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -1304,12 +1304,12 @@ NTSTATUS ndr_pull_DATA_BLOB(struct ndr_pull *ndr, DATA_BLOB *blob) return NT_STATUS_OK; } -uint32 ndr_size_DATA_BLOB(int ret, const DATA_BLOB *data, int flags) +uint32_t ndr_size_DATA_BLOB(int ret, const DATA_BLOB *data, int flags) { return ret + data->length; } -uint32 ndr_size_string(int ret, const char * const* string, int flags) +uint32_t ndr_size_string(int ret, const char * const* string, int flags) { /* FIXME: Is this correct for all strings ? */ if(!(*string)) return ret; -- cgit From 9b9c23b19be5a90821e1075a76f8b94fdb2424e2 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 1 Feb 2005 04:12:44 +0000 Subject: r5155: define ipv4address as a based IDL type, mapped to a "const char *" in the header, and defined on the wire as a 4 byte network byte order IP. This means the calling code doesn't have to worry about network byte order conversions. (This used to be commit 72048e37179dd5b9ada0c5280d2f0d8c23d1a17d) --- source4/librpc/ndr/ndr_basic.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 9601421044..507ee1594b 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -21,6 +21,7 @@ */ #include "includes.h" +#include "system/network.h" #define NDR_BE(ndr) (((ndr)->flags & (LIBNDR_FLAG_BIGENDIAN|LIBNDR_FLAG_LITTLE_ENDIAN)) == LIBNDR_FLAG_BIGENDIAN) #define NDR_SVAL(ndr, ofs) (NDR_BE(ndr)?RSVAL(ndr->data,ofs):SVAL(ndr->data,ofs)) @@ -1017,6 +1018,39 @@ NTSTATUS ndr_pull_time_t(struct ndr_pull *ndr, time_t *t) } +/* + pull a ipv4address +*/ +NTSTATUS ndr_pull_ipv4address(struct ndr_pull *ndr, const char **address) +{ + struct ipv4_addr in; + NDR_CHECK(ndr_pull_uint32(ndr, &in.addr)); + in.addr = htonl(in.addr); + *address = talloc_strdup(ndr, sys_inet_ntoa(in)); + NT_STATUS_HAVE_NO_MEMORY(*address); + return NT_STATUS_OK; +} + +/* + push a ipv4address +*/ +NTSTATUS ndr_push_ipv4address(struct ndr_push *ndr, const char *address) +{ + uint32_t addr = interpret_addr(address); + NDR_CHECK(ndr_push_uint32(ndr, htonl(addr))); + return NT_STATUS_OK; +} + +/* + print a ipv4address +*/ +void ndr_print_ipv4address(struct ndr_print *ndr, const char *name, + const char *address) +{ + ndr->print(ndr, "%-25s: %s", name, address); +} + + void ndr_print_struct(struct ndr_print *ndr, const char *name, const char *type) { ndr->print(ndr, "%s: struct %s", name, type); -- cgit From 632acd9bc7704ac3d326354808c3d12f4f0a9f8f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 9 Feb 2005 21:10:23 +0000 Subject: r5286: Some first steps in making the pidl code somewhat more generic for the various data types: Add ndr_flags argument to all ndr push/pull scalar functions (This used to be commit ab490c0c882bb13de190546c50a0631ecb8255ad) --- source4/librpc/ndr/ndr_basic.c | 158 ++++++++++++++++++++--------------------- 1 file changed, 79 insertions(+), 79 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 507ee1594b..5f61a59a07 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -59,7 +59,7 @@ void ndr_check_padding(struct ndr_pull *ndr, size_t n) /* parse a uint8 */ -NTSTATUS ndr_pull_uint8(struct ndr_pull *ndr, uint8_t *v) +NTSTATUS ndr_pull_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *v) { NDR_PULL_NEED_BYTES(ndr, 1); *v = CVAL(ndr->data, ndr->offset); @@ -71,7 +71,7 @@ NTSTATUS ndr_pull_uint8(struct ndr_pull *ndr, uint8_t *v) /* parse a uint16 */ -NTSTATUS ndr_pull_uint16(struct ndr_pull *ndr, uint16_t *v) +NTSTATUS ndr_pull_uint16(struct ndr_pull *ndr, int ndr_flags, uint16_t *v) { NDR_PULL_ALIGN(ndr, 2); NDR_PULL_NEED_BYTES(ndr, 2); @@ -84,7 +84,7 @@ NTSTATUS ndr_pull_uint16(struct ndr_pull *ndr, uint16_t *v) /* parse a uint32_t */ -NTSTATUS ndr_pull_uint32(struct ndr_pull *ndr, uint32_t *v) +NTSTATUS ndr_pull_uint32(struct ndr_pull *ndr, int ndr_flags, uint32_t *v) { NDR_PULL_ALIGN(ndr, 4); NDR_PULL_NEED_BYTES(ndr, 4); @@ -96,7 +96,7 @@ NTSTATUS ndr_pull_uint32(struct ndr_pull *ndr, uint32_t *v) /* parse a int32_t */ -NTSTATUS ndr_pull_int32(struct ndr_pull *ndr, int32_t *v) +NTSTATUS ndr_pull_int32(struct ndr_pull *ndr, int ndr_flags, int32_t *v) { NDR_PULL_ALIGN(ndr, 4); NDR_PULL_NEED_BYTES(ndr, 4); @@ -111,7 +111,7 @@ NTSTATUS ndr_pull_int32(struct ndr_pull *ndr, int32_t *v) NTSTATUS ndr_pull_ptr(struct ndr_pull *ndr, uint32_t *v) { NTSTATUS status; - status = ndr_pull_uint32(ndr, v); + status = ndr_pull_uint32(ndr, NDR_SCALARS, v); if (*v != 0) { ndr->ptr_count++; } @@ -121,7 +121,7 @@ NTSTATUS ndr_pull_ptr(struct ndr_pull *ndr, uint32_t *v) /* parse a udlong */ -NTSTATUS ndr_pull_udlong(struct ndr_pull *ndr, uint64_t *v) +NTSTATUS ndr_pull_udlong(struct ndr_pull *ndr, int ndr_flags, uint64_t *v) { NDR_PULL_ALIGN(ndr, 4); NDR_PULL_NEED_BYTES(ndr, 8); @@ -134,27 +134,27 @@ NTSTATUS ndr_pull_udlong(struct ndr_pull *ndr, uint64_t *v) /* parse a dlong */ -NTSTATUS ndr_pull_dlong(struct ndr_pull *ndr, int64_t *v) +NTSTATUS ndr_pull_dlong(struct ndr_pull *ndr, int ndr_flags, int64_t *v) { - return ndr_pull_udlong(ndr, (uint64_t *)v); + return ndr_pull_udlong(ndr, ndr_flags, (uint64_t *)v); } /* parse a hyper */ -NTSTATUS ndr_pull_hyper(struct ndr_pull *ndr, uint64_t *v) +NTSTATUS ndr_pull_hyper(struct ndr_pull *ndr, int ndr_flags, uint64_t *v) { NDR_PULL_ALIGN(ndr, 8); - return ndr_pull_udlong(ndr, v); + return ndr_pull_udlong(ndr, ndr_flags, v); } /* pull a NTSTATUS */ -NTSTATUS ndr_pull_NTSTATUS(struct ndr_pull *ndr, NTSTATUS *status) +NTSTATUS ndr_pull_NTSTATUS(struct ndr_pull *ndr, int ndr_flags, NTSTATUS *status) { uint32_t v; - NDR_CHECK(ndr_pull_uint32(ndr, &v)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v)); *status = NT_STATUS(v); return NT_STATUS_OK; } @@ -162,9 +162,9 @@ NTSTATUS ndr_pull_NTSTATUS(struct ndr_pull *ndr, NTSTATUS *status) /* push a NTSTATUS */ -NTSTATUS ndr_push_NTSTATUS(struct ndr_push *ndr, NTSTATUS status) +NTSTATUS ndr_push_NTSTATUS(struct ndr_push *ndr, int ndr_flags, NTSTATUS status) { - return ndr_push_uint32(ndr, NT_STATUS_V(status)); + return ndr_push_uint32(ndr, ndr_flags, NT_STATUS_V(status)); } void ndr_print_NTSTATUS(struct ndr_print *ndr, const char *name, NTSTATUS *r) @@ -175,10 +175,10 @@ void ndr_print_NTSTATUS(struct ndr_print *ndr, const char *name, NTSTATUS *r) /* pull a WERROR */ -NTSTATUS ndr_pull_WERROR(struct ndr_pull *ndr, WERROR *status) +NTSTATUS ndr_pull_WERROR(struct ndr_pull *ndr, int ndr_flags, WERROR *status) { uint32_t v; - NDR_CHECK(ndr_pull_uint32(ndr, &v)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v)); *status = W_ERROR(v); return NT_STATUS_OK; } @@ -186,9 +186,9 @@ NTSTATUS ndr_pull_WERROR(struct ndr_pull *ndr, WERROR *status) /* push a WERROR */ -NTSTATUS ndr_push_WERROR(struct ndr_push *ndr, WERROR status) +NTSTATUS ndr_push_WERROR(struct ndr_push *ndr, int ndr_flags, WERROR status) { - return ndr_push_uint32(ndr, W_ERROR_V(status)); + return ndr_push_uint32(ndr, NDR_SCALARS, W_ERROR_V(status)); } void ndr_print_WERROR(struct ndr_print *ndr, const char *name, WERROR r) @@ -229,7 +229,7 @@ NTSTATUS ndr_pull_array_uint16(struct ndr_pull *ndr, int ndr_flags, uint16_t *da return NT_STATUS_OK; } for (i=0;idata, ndr->offset, v); @@ -295,7 +295,7 @@ NTSTATUS ndr_push_uint8(struct ndr_push *ndr, uint8_t v) /* push a uint16 */ -NTSTATUS ndr_push_uint16(struct ndr_push *ndr, uint16_t v) +NTSTATUS ndr_push_uint16(struct ndr_push *ndr, int ndr_flags, uint16_t v) { NDR_PUSH_ALIGN(ndr, 2); NDR_PUSH_NEED_BYTES(ndr, 2); @@ -307,7 +307,7 @@ NTSTATUS ndr_push_uint16(struct ndr_push *ndr, uint16_t v) /* push a uint32_t */ -NTSTATUS ndr_push_uint32(struct ndr_push *ndr, uint32_t v) +NTSTATUS ndr_push_uint32(struct ndr_push *ndr, int ndr_flags, uint32_t v) { NDR_PUSH_ALIGN(ndr, 4); NDR_PUSH_NEED_BYTES(ndr, 4); @@ -319,7 +319,7 @@ NTSTATUS ndr_push_uint32(struct ndr_push *ndr, uint32_t v) /* push a int32_t */ -NTSTATUS ndr_push_int32(struct ndr_push *ndr, int32_t v) +NTSTATUS ndr_push_int32(struct ndr_push *ndr, int ndr_flags, int32_t v) { NDR_PUSH_ALIGN(ndr, 4); NDR_PUSH_NEED_BYTES(ndr, 4); @@ -331,7 +331,7 @@ NTSTATUS ndr_push_int32(struct ndr_push *ndr, int32_t v) /* push a uint64 */ -NTSTATUS ndr_push_udlong(struct ndr_push *ndr, uint64_t v) +NTSTATUS ndr_push_udlong(struct ndr_push *ndr, int ndr_flags, uint64_t v) { NDR_PUSH_ALIGN(ndr, 4); NDR_PUSH_NEED_BYTES(ndr, 8); @@ -344,18 +344,18 @@ NTSTATUS ndr_push_udlong(struct ndr_push *ndr, uint64_t v) /* push a int64 */ -NTSTATUS ndr_push_dlong(struct ndr_push *ndr, int64_t v) +NTSTATUS ndr_push_dlong(struct ndr_push *ndr, int ndr_flags, int64_t v) { - return ndr_push_udlong(ndr, (uint64_t)v); + return ndr_push_udlong(ndr, NDR_SCALARS, (uint64_t)v); } /* push a hyper */ -NTSTATUS ndr_push_hyper(struct ndr_push *ndr, uint64_t v) +NTSTATUS ndr_push_hyper(struct ndr_push *ndr, int ndr_flags, uint64_t v) { NDR_PUSH_ALIGN(ndr, 8); - return ndr_push_udlong(ndr, v); + return ndr_push_udlong(ndr, NDR_SCALARS, v); } NTSTATUS ndr_push_align(struct ndr_push *ndr, size_t size) @@ -413,7 +413,7 @@ NTSTATUS ndr_push_array_uint16(struct ndr_push *ndr, int ndr_flags, const uint16 return NT_STATUS_OK; } for (i=0;iptr_count++; ptr = ndr->ptr_count; } - return ndr_push_uint32(ndr, ptr); + return ndr_push_uint32(ndr, NDR_SCALARS, ptr); } @@ -539,13 +539,13 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) switch (flags & LIBNDR_STRING_FLAGS) { case LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4: case LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_NOTERM: - NDR_CHECK(ndr_pull_uint32(ndr, &len1)); - NDR_CHECK(ndr_pull_uint32(ndr, &ofs)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &len1)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &ofs)); if (ofs != 0) { return ndr_pull_error(ndr, NDR_ERR_STRING, "non-zero array offset with string flags 0x%x\n", ndr->flags & LIBNDR_STRING_FLAGS); } - NDR_CHECK(ndr_pull_uint32(ndr, &len2)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &len2)); if (len2 > len1) { return ndr_pull_error(ndr, NDR_ERR_STRING, "Bad string lengths len1=%u ofs=%u len2=%u\n", @@ -582,7 +582,7 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) case LIBNDR_FLAG_STR_SIZE4: case LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_NOTERM: - NDR_CHECK(ndr_pull_uint32(ndr, &len1)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &len1)); NDR_PULL_NEED_BYTES(ndr, (len1 + c_len_term)*byte_mul); if (len1 == 0) { *s = talloc_strdup(ndr, ""); @@ -614,12 +614,12 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) case LIBNDR_FLAG_STR_LEN4: case LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_NOTERM: - NDR_CHECK(ndr_pull_uint32(ndr, &ofs)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &ofs)); if (ofs != 0) { return ndr_pull_error(ndr, NDR_ERR_STRING, "non-zero array offset with string flags 0x%x\n", ndr->flags & LIBNDR_STRING_FLAGS); } - NDR_CHECK(ndr_pull_uint32(ndr, &len1)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &len1)); NDR_PULL_NEED_BYTES(ndr, (len1 + c_len_term)*byte_mul); if (len1 == 0) { *s = talloc_strdup(ndr, ""); @@ -652,7 +652,7 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) case LIBNDR_FLAG_STR_SIZE2: case LIBNDR_FLAG_STR_SIZE2|LIBNDR_FLAG_STR_NOTERM: - NDR_CHECK(ndr_pull_uint16(ndr, &len3)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &len3)); NDR_PULL_NEED_BYTES(ndr, (len3 + c_len_term)*byte_mul); if (len3 == 0) { *s = talloc_strdup(ndr, ""); @@ -683,7 +683,7 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) break; case LIBNDR_FLAG_STR_SIZE2|LIBNDR_FLAG_STR_NOTERM|LIBNDR_FLAG_STR_BYTESIZE: - NDR_CHECK(ndr_pull_uint16(ndr, &len3)); + NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &len3)); NDR_PULL_NEED_BYTES(ndr, len3); if (len3 == 0) { *s = talloc_strdup(ndr, ""); @@ -788,9 +788,9 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) switch (flags & LIBNDR_STRING_FLAGS) { case LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4: - NDR_CHECK(ndr_push_uint32(ndr, c_len+c_len_term)); - NDR_CHECK(ndr_push_uint32(ndr, 0)); - NDR_CHECK(ndr_push_uint32(ndr, c_len+c_len_term)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, c_len+c_len_term)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, c_len+c_len_term)); NDR_PUSH_NEED_BYTES(ndr, byte_mul*(c_len+1)); ret = convert_string(CH_UNIX, chset, s, s_len+1, @@ -804,9 +804,9 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) break; case LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_NOTERM: - NDR_CHECK(ndr_push_uint32(ndr, c_len)); - NDR_CHECK(ndr_push_uint32(ndr, 0)); - NDR_CHECK(ndr_push_uint32(ndr, c_len)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, c_len)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, c_len)); NDR_PUSH_NEED_BYTES(ndr, c_len*byte_mul); ret = convert_string(CH_UNIX, chset, s, s_len, @@ -819,8 +819,8 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) break; case LIBNDR_FLAG_STR_LEN4: - NDR_CHECK(ndr_push_uint32(ndr, 0)); - NDR_CHECK(ndr_push_uint32(ndr, c_len + c_len_term)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, c_len + c_len_term)); NDR_PUSH_NEED_BYTES(ndr, byte_mul*(c_len+1)); ret = convert_string(CH_UNIX, chset, s, s_len + 1, @@ -833,7 +833,7 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) break; case LIBNDR_FLAG_STR_SIZE4: - NDR_CHECK(ndr_push_uint32(ndr, c_len + c_len_term)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, c_len + c_len_term)); NDR_PUSH_NEED_BYTES(ndr, byte_mul*(c_len+1)); ret = convert_string(CH_UNIX, chset, s, s_len + 1, @@ -846,7 +846,7 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) break; case LIBNDR_FLAG_STR_SIZE2: - NDR_CHECK(ndr_push_uint16(ndr, c_len + c_len_term)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, c_len + c_len_term)); NDR_PUSH_NEED_BYTES(ndr, byte_mul*(c_len+1)); ret = convert_string(CH_UNIX, chset, s, s_len + 1, @@ -871,7 +871,7 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) break; case LIBNDR_FLAG_STR_SIZE2|LIBNDR_FLAG_STR_NOTERM|LIBNDR_FLAG_STR_BYTESIZE: - NDR_CHECK(ndr_push_uint16(ndr, c_len*byte_mul)); + NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, c_len*byte_mul)); NDR_PUSH_NEED_BYTES(ndr, c_len*byte_mul); ret = convert_string(CH_UNIX, chset, s, s_len, @@ -945,37 +945,37 @@ size_t ndr_string_array_size(struct ndr_push *ndr, const char *s) /* push a NTTIME */ -NTSTATUS ndr_push_NTTIME(struct ndr_push *ndr, NTTIME t) +NTSTATUS ndr_push_NTTIME(struct ndr_push *ndr, int ndr_flags, NTTIME t) { - NDR_CHECK(ndr_push_udlong(ndr, t)); + NDR_CHECK(ndr_push_udlong(ndr, ndr_flags, t)); return NT_STATUS_OK; } /* pull a NTTIME */ -NTSTATUS ndr_pull_NTTIME(struct ndr_pull *ndr, NTTIME *t) +NTSTATUS ndr_pull_NTTIME(struct ndr_pull *ndr, int ndr_flags, NTTIME *t) { - NDR_CHECK(ndr_pull_udlong(ndr, t)); + NDR_CHECK(ndr_pull_udlong(ndr, ndr_flags, t)); return NT_STATUS_OK; } /* push a NTTIME */ -NTSTATUS ndr_push_NTTIME_1sec(struct ndr_push *ndr, NTTIME t) +NTSTATUS ndr_push_NTTIME_1sec(struct ndr_push *ndr, int ndr_flags, NTTIME t) { t /= 10000000; - NDR_CHECK(ndr_push_hyper(ndr, t)); + NDR_CHECK(ndr_push_hyper(ndr, ndr_flags, t)); return NT_STATUS_OK; } /* pull a NTTIME_1sec */ -NTSTATUS ndr_pull_NTTIME_1sec(struct ndr_pull *ndr, NTTIME *t) +NTSTATUS ndr_pull_NTTIME_1sec(struct ndr_pull *ndr, int ndr_flags, NTTIME *t) { - NDR_CHECK(ndr_pull_hyper(ndr, t)); + NDR_CHECK(ndr_pull_hyper(ndr, ndr_flags, t)); (*t) *= 10000000; return NT_STATUS_OK; } @@ -983,36 +983,36 @@ NTSTATUS ndr_pull_NTTIME_1sec(struct ndr_pull *ndr, NTTIME *t) /* pull a NTTIME_hyper */ -NTSTATUS ndr_pull_NTTIME_hyper(struct ndr_pull *ndr, NTTIME *t) +NTSTATUS ndr_pull_NTTIME_hyper(struct ndr_pull *ndr, int ndr_flags, NTTIME *t) { - NDR_CHECK(ndr_pull_hyper(ndr, t)); + NDR_CHECK(ndr_pull_hyper(ndr, ndr_flags, t)); return NT_STATUS_OK; } /* push a NTTIME_hyper */ -NTSTATUS ndr_push_NTTIME_hyper(struct ndr_push *ndr, NTTIME t) +NTSTATUS ndr_push_NTTIME_hyper(struct ndr_push *ndr, int ndr_flags, NTTIME t) { - NDR_CHECK(ndr_push_hyper(ndr, t)); + NDR_CHECK(ndr_push_hyper(ndr, ndr_flags, t)); return NT_STATUS_OK; } /* push a time_t */ -NTSTATUS ndr_push_time_t(struct ndr_push *ndr, time_t t) +NTSTATUS ndr_push_time_t(struct ndr_push *ndr, int ndr_flags, time_t t) { - return ndr_push_uint32(ndr, t); + return ndr_push_uint32(ndr, ndr_flags, t); } /* pull a time_t */ -NTSTATUS ndr_pull_time_t(struct ndr_pull *ndr, time_t *t) +NTSTATUS ndr_pull_time_t(struct ndr_pull *ndr, int ndr_flags, time_t *t) { uint32_t tt; - NDR_CHECK(ndr_pull_uint32(ndr, &tt)); + NDR_CHECK(ndr_pull_uint32(ndr, ndr_flags, &tt)); *t = tt; return NT_STATUS_OK; } @@ -1021,10 +1021,10 @@ NTSTATUS ndr_pull_time_t(struct ndr_pull *ndr, time_t *t) /* pull a ipv4address */ -NTSTATUS ndr_pull_ipv4address(struct ndr_pull *ndr, const char **address) +NTSTATUS ndr_pull_ipv4address(struct ndr_pull *ndr, int ndr_flags, const char **address) { struct ipv4_addr in; - NDR_CHECK(ndr_pull_uint32(ndr, &in.addr)); + NDR_CHECK(ndr_pull_uint32(ndr, ndr_flags, &in.addr)); in.addr = htonl(in.addr); *address = talloc_strdup(ndr, sys_inet_ntoa(in)); NT_STATUS_HAVE_NO_MEMORY(*address); @@ -1034,10 +1034,10 @@ NTSTATUS ndr_pull_ipv4address(struct ndr_pull *ndr, const char **address) /* push a ipv4address */ -NTSTATUS ndr_push_ipv4address(struct ndr_push *ndr, const char *address) +NTSTATUS ndr_push_ipv4address(struct ndr_push *ndr, int ndr_flags, const char *address) { uint32_t addr = interpret_addr(address); - NDR_CHECK(ndr_push_uint32(ndr, htonl(addr))); + NDR_CHECK(ndr_push_uint32(ndr, ndr_flags, htonl(addr))); return NT_STATUS_OK; } @@ -1290,7 +1290,7 @@ void ndr_print_DATA_BLOB(struct ndr_print *ndr, const char *name, DATA_BLOB r) /* push a DATA_BLOB onto the wire. */ -NTSTATUS ndr_push_DATA_BLOB(struct ndr_push *ndr, DATA_BLOB blob) +NTSTATUS ndr_push_DATA_BLOB(struct ndr_push *ndr, int ndr_flags, DATA_BLOB blob) { if (ndr->flags & LIBNDR_ALIGN_FLAGS) { if (ndr->flags & LIBNDR_FLAG_ALIGN2) { @@ -1303,7 +1303,7 @@ NTSTATUS ndr_push_DATA_BLOB(struct ndr_push *ndr, DATA_BLOB blob) NDR_PUSH_ALLOC_SIZE(ndr, blob.data, blob.length); data_blob_clear(&blob); } else if (!(ndr->flags & LIBNDR_FLAG_REMAINING)) { - NDR_CHECK(ndr_push_uint32(ndr, blob.length)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, blob.length)); } NDR_CHECK(ndr_push_bytes(ndr, blob.data, blob.length)); return NT_STATUS_OK; @@ -1312,7 +1312,7 @@ NTSTATUS ndr_push_DATA_BLOB(struct ndr_push *ndr, DATA_BLOB blob) /* pull a DATA_BLOB from the wire. */ -NTSTATUS ndr_pull_DATA_BLOB(struct ndr_pull *ndr, DATA_BLOB *blob) +NTSTATUS ndr_pull_DATA_BLOB(struct ndr_pull *ndr, int ndr_flags, DATA_BLOB *blob) { uint32_t length; @@ -1330,7 +1330,7 @@ NTSTATUS ndr_pull_DATA_BLOB(struct ndr_pull *ndr, DATA_BLOB *blob) } else if (ndr->flags & LIBNDR_FLAG_REMAINING) { length = ndr->data_size - ndr->offset; } else { - NDR_CHECK(ndr_pull_uint32(ndr, &length)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &length)); } NDR_PULL_NEED_BYTES(ndr, length); *blob = data_blob_talloc(ndr, ndr->data+ndr->offset, length); -- cgit From 51a6f7b227e131a7610b56cbf54d9128f35c7d66 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 12 Feb 2005 21:43:08 +0000 Subject: r5361: Rename some functions, add tests to validator. (This used to be commit c9d7b88756039a3eb3024c886851e489c46ef67f) --- source4/librpc/ndr/ndr_basic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 5f61a59a07..281980fb4c 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -106,7 +106,7 @@ NTSTATUS ndr_pull_int32(struct ndr_pull *ndr, int ndr_flags, int32_t *v) } /* - parse a pointer + parse a pointer referent identifier */ NTSTATUS ndr_pull_ptr(struct ndr_pull *ndr, uint32_t *v) { -- cgit From 2f8478b27d4929d5f7ea8f92f61df57dd869ede6 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 13 Feb 2005 00:07:17 +0000 Subject: r5363: - ndr_%_ptr -> ndr_%_unique_ptr - ndr_%_relative% -> ndr_%_relative_ptr% - Change pointer_default() default to "unique" (DCE uses "ptr" as default, MIDL doesn't follow the standard and uses "unique") (This used to be commit 53b4ecbcc7a8da67cde1377de6f24a3de6d229e3) --- source4/librpc/ndr/ndr_basic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 281980fb4c..8f43d6c18a 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -108,7 +108,7 @@ NTSTATUS ndr_pull_int32(struct ndr_pull *ndr, int ndr_flags, int32_t *v) /* parse a pointer referent identifier */ -NTSTATUS ndr_pull_ptr(struct ndr_pull *ndr, uint32_t *v) +NTSTATUS ndr_pull_unique_ptr(struct ndr_pull *ndr, uint32_t *v) { NTSTATUS status; status = ndr_pull_uint32(ndr, NDR_SCALARS, v); @@ -482,7 +482,7 @@ void ndr_push_restore(struct ndr_push *ndr, struct ndr_push_save *save) /* push a 1 if a pointer is non-NULL, otherwise 0 */ -NTSTATUS ndr_push_ptr(struct ndr_push *ndr, const void *p) +NTSTATUS ndr_push_unique_ptr(struct ndr_push *ndr, const void *p) { uint32_t ptr = 0; if (p) { -- cgit From ff6e58a7c4da70880276aad482820b0d17be635b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 13 Feb 2005 12:38:56 +0000 Subject: r5376: ORPC is NDR specific, so move it to ndr.pm. Get rid of register_enum/register_bitmap, etc. (use list of types in ndr.pm instead) (This used to be commit efc2e41b8df3a0171cca57291929fb63760c1662) --- source4/librpc/ndr/ndr_basic.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 8f43d6c18a..5eecb1d60b 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -486,9 +486,6 @@ NTSTATUS ndr_push_unique_ptr(struct ndr_push *ndr, const void *p) { uint32_t ptr = 0; if (p) { - /* we do this to ensure that we generate unique ref ids, - which means we can handle the case where a MS programmer - forgot to mark a pointer as unique */ ndr->ptr_count++; ptr = ndr->ptr_count; } -- cgit From a6878f6c6e17ea99baf57e5724d524548a44ada8 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 16 Feb 2005 10:03:18 +0000 Subject: r5414: - added libcli/wins/, a basic client library for WINS replication - added a new IDL type "udlongr", which is like udlong, but with the two uint32 halves reversed - modified the winsrepl.idl to cope with a wider range of packets (This used to be commit bc8d60c918f2e268d591aac464fc6a78c38a4cf9) --- source4/librpc/ndr/ndr_basic.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 5eecb1d60b..5f91cef2e8 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -131,6 +131,19 @@ NTSTATUS ndr_pull_udlong(struct ndr_pull *ndr, int ndr_flags, uint64_t *v) return NT_STATUS_OK; } +/* + parse a udlongr +*/ +NTSTATUS ndr_pull_udlongr(struct ndr_pull *ndr, int ndr_flags, uint64_t *v) +{ + NDR_PULL_ALIGN(ndr, 4); + NDR_PULL_NEED_BYTES(ndr, 8); + *v = ((uint64_t)NDR_IVAL(ndr, ndr->offset)) << 32; + *v |= NDR_IVAL(ndr, ndr->offset+4); + ndr->offset += 8; + return NT_STATUS_OK; +} + /* parse a dlong */ @@ -329,7 +342,7 @@ NTSTATUS ndr_push_int32(struct ndr_push *ndr, int ndr_flags, int32_t v) } /* - push a uint64 + push a udlong */ NTSTATUS ndr_push_udlong(struct ndr_push *ndr, int ndr_flags, uint64_t v) { @@ -341,6 +354,19 @@ NTSTATUS ndr_push_udlong(struct ndr_push *ndr, int ndr_flags, uint64_t v) return NT_STATUS_OK; } +/* + push a udlongr +*/ +NTSTATUS ndr_push_udlongr(struct ndr_push *ndr, int ndr_flags, uint64_t v) +{ + NDR_PUSH_ALIGN(ndr, 4); + NDR_PUSH_NEED_BYTES(ndr, 8); + NDR_SIVAL(ndr, ndr->offset+4, (v>>32)); + NDR_SIVAL(ndr, ndr->offset, (v & 0xFFFFFFFF)); + ndr->offset += 8; + return NT_STATUS_OK; +} + /* push a int64 */ @@ -1107,6 +1133,11 @@ void ndr_print_udlong(struct ndr_print *ndr, const char *name, uint64_t v) v); } +void ndr_print_udlongr(struct ndr_print *ndr, const char *name, uint64_t v) +{ + ndr_print_udlong(ndr, name, v); +} + void ndr_print_dlong(struct ndr_print *ndr, const char *name, int64_t v) { ndr->print(ndr, "%-25s: 0x%08x%08x (%lld)", name, -- cgit From a2aa220709eca6dd260d9eeecf918f9bb129d8ed Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 17 Feb 2005 11:42:38 +0000 Subject: r5427: NTSTATUS is treated by pidl as a 'real' scalar now. (This used to be commit fa97059d000859b3d0192ed4a0135770888aba6f) --- source4/librpc/ndr/ndr_basic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 5f91cef2e8..24ca8dcd0e 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -180,9 +180,9 @@ NTSTATUS ndr_push_NTSTATUS(struct ndr_push *ndr, int ndr_flags, NTSTATUS status) return ndr_push_uint32(ndr, ndr_flags, NT_STATUS_V(status)); } -void ndr_print_NTSTATUS(struct ndr_print *ndr, const char *name, NTSTATUS *r) +void ndr_print_NTSTATUS(struct ndr_print *ndr, const char *name, NTSTATUS r) { - ndr->print(ndr, "%-25s: %s", name, nt_errstr(*r)); + ndr->print(ndr, "%-25s: %s", name, nt_errstr(r)); } /* -- cgit From e90c904a5f9b3b10a2e304be3a532ceb83424cb5 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 12 Mar 2005 08:29:54 +0000 Subject: r5764: add support for embedded ref pointers metze (This used to be commit 112043b1809a96b1a39ade71ea2885c0d792c79f) --- source4/librpc/ndr/ndr_basic.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 24ca8dcd0e..0ea38c21c2 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -118,6 +118,18 @@ NTSTATUS ndr_pull_unique_ptr(struct ndr_pull *ndr, uint32_t *v) return status; } +/* + parse a ref pointer referent identifier +*/ +NTSTATUS ndr_pull_ref_ptr(struct ndr_pull *ndr, uint32_t *v) +{ + NTSTATUS status; + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, v)); + /* ref pointers always point to data */ + *v = 1; + return status; +} + /* parse a udlong */ @@ -506,7 +518,7 @@ void ndr_push_restore(struct ndr_push *ndr, struct ndr_push_save *save) } /* - push a 1 if a pointer is non-NULL, otherwise 0 + push a unique non-zero value if a pointer is non-NULL, otherwise 0 */ NTSTATUS ndr_push_unique_ptr(struct ndr_push *ndr, const void *p) { @@ -518,6 +530,17 @@ NTSTATUS ndr_push_unique_ptr(struct ndr_push *ndr, const void *p) return ndr_push_uint32(ndr, NDR_SCALARS, ptr); } +/* + push always a 0, if a pointer is NULL it's a fatal error +*/ +NTSTATUS ndr_push_ref_ptr(struct ndr_push *ndr, const void *p) +{ + uint32_t ptr = 0; + if (p == NULL) { + return NT_STATUS_INVALID_PARAMETER_MIX; + } + return ndr_push_uint32(ndr, NDR_SCALARS, 0); +} /* pull a general string from the wire -- cgit From 26cb89fcdddbbfab0884202a9d669c33e2fd6bb0 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 12 Mar 2005 08:51:37 +0000 Subject: r5765: remove unused var metze (This used to be commit a8f7c3e59f35127b51d4afc551b71f21886f4565) --- source4/librpc/ndr/ndr_basic.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 0ea38c21c2..0f745b3105 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -535,7 +535,6 @@ NTSTATUS ndr_push_unique_ptr(struct ndr_push *ndr, const void *p) */ NTSTATUS ndr_push_ref_ptr(struct ndr_push *ndr, const void *p) { - uint32_t ptr = 0; if (p == NULL) { return NT_STATUS_INVALID_PARAMETER_MIX; } -- cgit From ebc34d215780e33eb1b1fa377c5f76f425df35f1 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 15 Mar 2005 14:25:59 +0000 Subject: r5796: add ndr_* function for int8 and int16 metze (This used to be commit 8ac0928a914c1cee3f0493b515f03c6422a8b71a) --- source4/librpc/ndr/ndr_basic.c | 99 ++++++++++++++++++++++++++++++++---------- 1 file changed, 75 insertions(+), 24 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 0f745b3105..3e192d03a2 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -57,7 +57,18 @@ void ndr_check_padding(struct ndr_pull *ndr, size_t n) } /* - parse a uint8 + parse a int8_t +*/ +NTSTATUS ndr_pull_int8(struct ndr_pull *ndr, int ndr_flags, int8_t *v) +{ + NDR_PULL_NEED_BYTES(ndr, 1); + *v = (int8_t)CVAL(ndr->data, ndr->offset); + ndr->offset += 1; + return NT_STATUS_OK; +} + +/* + parse a uint8_t */ NTSTATUS ndr_pull_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *v) { @@ -67,9 +78,20 @@ NTSTATUS ndr_pull_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *v) return NT_STATUS_OK; } +/* + parse a int16_t +*/ +NTSTATUS ndr_pull_int16(struct ndr_pull *ndr, int ndr_flags, int16_t *v) +{ + NDR_PULL_ALIGN(ndr, 2); + NDR_PULL_NEED_BYTES(ndr, 2); + *v = (uint16_t)NDR_SVAL(ndr, ndr->offset); + ndr->offset += 2; + return NT_STATUS_OK; +} /* - parse a uint16 + parse a uint16_t */ NTSTATUS ndr_pull_uint16(struct ndr_pull *ndr, int ndr_flags, uint16_t *v) { @@ -80,27 +102,26 @@ NTSTATUS ndr_pull_uint16(struct ndr_pull *ndr, int ndr_flags, uint16_t *v) return NT_STATUS_OK; } - /* - parse a uint32_t + parse a int32_t */ -NTSTATUS ndr_pull_uint32(struct ndr_pull *ndr, int ndr_flags, uint32_t *v) +NTSTATUS ndr_pull_int32(struct ndr_pull *ndr, int ndr_flags, int32_t *v) { NDR_PULL_ALIGN(ndr, 4); NDR_PULL_NEED_BYTES(ndr, 4); - *v = NDR_IVAL(ndr, ndr->offset); + *v = NDR_IVALS(ndr, ndr->offset); ndr->offset += 4; return NT_STATUS_OK; } /* - parse a int32_t + parse a uint32_t */ -NTSTATUS ndr_pull_int32(struct ndr_pull *ndr, int ndr_flags, int32_t *v) +NTSTATUS ndr_pull_uint32(struct ndr_pull *ndr, int ndr_flags, uint32_t *v) { NDR_PULL_ALIGN(ndr, 4); NDR_PULL_NEED_BYTES(ndr, 4); - *v = NDR_IVALS(ndr, ndr->offset); + *v = NDR_IVAL(ndr, ndr->offset); ndr->offset += 4; return NT_STATUS_OK; } @@ -243,7 +264,6 @@ NTSTATUS ndr_pull_array_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *data return ndr_pull_bytes(ndr, data, n); } - /* pull an array of uint16 */ @@ -304,10 +324,19 @@ NTSTATUS ndr_pull_array_WERROR(struct ndr_pull *ndr, int ndr_flags, WERROR *data return NT_STATUS_OK; } - +/* + push a int8_t +*/ +NTSTATUS ndr_push_int8(struct ndr_push *ndr, int ndr_flags, int8_t v) +{ + NDR_PUSH_NEED_BYTES(ndr, 1); + SCVAL(ndr->data, ndr->offset, (uint8_t)v); + ndr->offset += 1; + return NT_STATUS_OK; +} /* - push a uint8 + push a uint8_t */ NTSTATUS ndr_push_uint8(struct ndr_push *ndr, int ndr_flags, uint8_t v) { @@ -318,7 +347,19 @@ NTSTATUS ndr_push_uint8(struct ndr_push *ndr, int ndr_flags, uint8_t v) } /* - push a uint16 + push a int16_t +*/ +NTSTATUS ndr_push_int16(struct ndr_push *ndr, int ndr_flags, int16_t v) +{ + NDR_PUSH_ALIGN(ndr, 2); + NDR_PUSH_NEED_BYTES(ndr, 2); + NDR_SSVAL(ndr, ndr->offset, (uint16_t)v); + ndr->offset += 2; + return NT_STATUS_OK; +} + +/* + push a uint16_t */ NTSTATUS ndr_push_uint16(struct ndr_push *ndr, int ndr_flags, uint16_t v) { @@ -330,25 +371,25 @@ NTSTATUS ndr_push_uint16(struct ndr_push *ndr, int ndr_flags, uint16_t v) } /* - push a uint32_t + push a int32_t */ -NTSTATUS ndr_push_uint32(struct ndr_push *ndr, int ndr_flags, uint32_t v) +NTSTATUS ndr_push_int32(struct ndr_push *ndr, int ndr_flags, int32_t v) { NDR_PUSH_ALIGN(ndr, 4); NDR_PUSH_NEED_BYTES(ndr, 4); - NDR_SIVAL(ndr, ndr->offset, v); + NDR_SIVALS(ndr, ndr->offset, v); ndr->offset += 4; return NT_STATUS_OK; } /* - push a int32_t + push a uint32_t */ -NTSTATUS ndr_push_int32(struct ndr_push *ndr, int ndr_flags, int32_t v) +NTSTATUS ndr_push_uint32(struct ndr_push *ndr, int ndr_flags, uint32_t v) { NDR_PUSH_ALIGN(ndr, 4); NDR_PUSH_NEED_BYTES(ndr, 4); - NDR_SIVALS(ndr, ndr->offset, v); + NDR_SIVAL(ndr, ndr->offset, v); ndr->offset += 4; return NT_STATUS_OK; } @@ -380,7 +421,7 @@ NTSTATUS ndr_push_udlongr(struct ndr_push *ndr, int ndr_flags, uint64_t v) } /* - push a int64 + push a dlong */ NTSTATUS ndr_push_dlong(struct ndr_push *ndr, int ndr_flags, int64_t v) { @@ -1127,19 +1168,24 @@ void ndr_print_bitmap_flag(struct ndr_print *ndr, size_t size, const char *flag_ } } +void ndr_print_int8(struct ndr_print *ndr, const char *name, int8_t v) +{ + ndr->print(ndr, "%-25s: %d", name, v); +} + void ndr_print_uint8(struct ndr_print *ndr, const char *name, uint8_t v) { ndr->print(ndr, "%-25s: 0x%02x (%u)", name, v, v); } -void ndr_print_uint16(struct ndr_print *ndr, const char *name, uint16_t v) +void ndr_print_int16(struct ndr_print *ndr, const char *name, int16_t v) { - ndr->print(ndr, "%-25s: 0x%04x (%u)", name, v, v); + ndr->print(ndr, "%-25s: %d", name, v); } -void ndr_print_uint32(struct ndr_print *ndr, const char *name, uint32_t v) +void ndr_print_uint16(struct ndr_print *ndr, const char *name, uint16_t v) { - ndr->print(ndr, "%-25s: 0x%08x (%u)", name, v, v); + ndr->print(ndr, "%-25s: 0x%04x (%u)", name, v, v); } void ndr_print_int32(struct ndr_print *ndr, const char *name, int32_t v) @@ -1147,6 +1193,11 @@ void ndr_print_int32(struct ndr_print *ndr, const char *name, int32_t v) ndr->print(ndr, "%-25s: %d", name, v); } +void ndr_print_uint32(struct ndr_print *ndr, const char *name, uint32_t v) +{ + ndr->print(ndr, "%-25s: 0x%08x (%u)", name, v, v); +} + void ndr_print_udlong(struct ndr_print *ndr, const char *name, uint64_t v) { ndr->print(ndr, "%-25s: 0x%08x%08x (%llu)", name, -- cgit From ef213b02482194a8fed7f37123e08624072694b2 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 17 Mar 2005 20:28:01 +0000 Subject: r5866: Add InitShutdown IDL and torture test. Implement push side of NDR_LEN4|NDR_NOTERM strings (pull side was already present) (This used to be commit ea61ec1122841716ed5d90085ba79e7bf691bd6a) --- source4/librpc/ndr/ndr_basic.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 3e192d03a2..8284375be5 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -918,6 +918,20 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) ndr->offset += byte_mul*(c_len+1); break; + case LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_NOTERM: + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, c_len)); + NDR_PUSH_NEED_BYTES(ndr, byte_mul*c_len); + ret = convert_string(CH_UNIX, chset, + s, s_len, + ndr->data+ndr->offset, byte_mul*c_len); + if (ret == -1) { + return ndr_push_error(ndr, NDR_ERR_CHARCNV, + "Bad character conversion"); + } + ndr->offset += byte_mul*c_len; + break; + case LIBNDR_FLAG_STR_SIZE4: NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, c_len + c_len_term)); NDR_PUSH_NEED_BYTES(ndr, byte_mul*(c_len+1)); -- cgit From 4c4738938a6681c8691f2c17cbdb23c707272251 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 22 Mar 2005 23:00:12 +0000 Subject: r5977: Fix uninitialised memory bug in ndr_pull_ref_ptr(). This fixes the Test_DoublePointer test failure. (This used to be commit 4089d5f67d6e4121056a63ececb13187fd773636) --- source4/librpc/ndr/ndr_basic.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 8284375be5..ef52a10efa 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -144,11 +144,10 @@ NTSTATUS ndr_pull_unique_ptr(struct ndr_pull *ndr, uint32_t *v) */ NTSTATUS ndr_pull_ref_ptr(struct ndr_pull *ndr, uint32_t *v) { - NTSTATUS status; NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, v)); /* ref pointers always point to data */ *v = 1; - return status; + return NT_STATUS_OK; } /* -- cgit From 14b63614fae318b46539706318dcd3954836172a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 29 Apr 2005 19:16:39 +0000 Subject: r6519: move string handling functions to a seperate file metze (This used to be commit a29d52817ce943c15f6896b74273df739867c8f7) --- source4/librpc/ndr/ndr_basic.c | 476 ----------------------------------------- 1 file changed, 476 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index ef52a10efa..31a1c816b4 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -23,7 +23,6 @@ #include "includes.h" #include "system/network.h" -#define NDR_BE(ndr) (((ndr)->flags & (LIBNDR_FLAG_BIGENDIAN|LIBNDR_FLAG_LITTLE_ENDIAN)) == LIBNDR_FLAG_BIGENDIAN) #define NDR_SVAL(ndr, ofs) (NDR_BE(ndr)?RSVAL(ndr->data,ofs):SVAL(ndr->data,ofs)) #define NDR_IVAL(ndr, ofs) (NDR_BE(ndr)?RIVAL(ndr->data,ofs):IVAL(ndr->data,ofs)) #define NDR_IVALS(ndr, ofs) (NDR_BE(ndr)?RIVALS(ndr->data,ofs):IVALS(ndr->data,ofs)) @@ -581,465 +580,6 @@ NTSTATUS ndr_push_ref_ptr(struct ndr_push *ndr, const void *p) return ndr_push_uint32(ndr, NDR_SCALARS, 0); } -/* - pull a general string from the wire -*/ -NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) -{ - char *as=NULL; - uint32_t len1, ofs, len2; - uint16_t len3; - int ret; - int chset = CH_UTF16; - unsigned byte_mul = 2; - unsigned flags = ndr->flags; - unsigned c_len_term = 0; - - if (!(ndr_flags & NDR_SCALARS)) { - return NT_STATUS_OK; - } - - if (NDR_BE(ndr)) { - chset = CH_UTF16BE; - } - - if (flags & LIBNDR_FLAG_STR_ASCII) { - chset = CH_DOS; - byte_mul = 1; - flags &= ~LIBNDR_FLAG_STR_ASCII; - } - - if (flags & LIBNDR_FLAG_STR_UTF8) { - chset = CH_UTF8; - byte_mul = 1; - flags &= ~LIBNDR_FLAG_STR_UTF8; - } - - flags &= ~LIBNDR_FLAG_STR_CONFORMANT; - if (flags & LIBNDR_FLAG_STR_CHARLEN) { - c_len_term = 1; - flags &= ~LIBNDR_FLAG_STR_CHARLEN; - } - - switch (flags & LIBNDR_STRING_FLAGS) { - case LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4: - case LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_NOTERM: - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &len1)); - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &ofs)); - if (ofs != 0) { - return ndr_pull_error(ndr, NDR_ERR_STRING, "non-zero array offset with string flags 0x%x\n", - ndr->flags & LIBNDR_STRING_FLAGS); - } - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &len2)); - if (len2 > len1) { - return ndr_pull_error(ndr, NDR_ERR_STRING, - "Bad string lengths len1=%u ofs=%u len2=%u\n", - len1, ofs, len2); - } - if (len2 == 0) { - *s = talloc_strdup(ndr, ""); - break; - } - NDR_PULL_NEED_BYTES(ndr, (len2 + c_len_term)*byte_mul); - ret = convert_string_talloc(ndr, chset, CH_UNIX, - ndr->data+ndr->offset, - (len2 + c_len_term)*byte_mul, - (void **)&as); - if (ret == -1) { - return ndr_pull_error(ndr, NDR_ERR_CHARCNV, - "Bad character conversion"); - } - NDR_CHECK(ndr_pull_advance(ndr, (len2 + c_len_term)*byte_mul)); - - /* this is a way of detecting if a string is sent with the wrong - termination */ - if (ndr->flags & LIBNDR_FLAG_STR_NOTERM) { - if (strlen(as) < (len2 + c_len_term)) { - DEBUG(6,("short string '%s'\n", as)); - } - } else { - if (strlen(as) == (len2 + c_len_term)) { - DEBUG(6,("long string '%s'\n", as)); - } - } - *s = as; - break; - - case LIBNDR_FLAG_STR_SIZE4: - case LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_NOTERM: - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &len1)); - NDR_PULL_NEED_BYTES(ndr, (len1 + c_len_term)*byte_mul); - if (len1 == 0) { - *s = talloc_strdup(ndr, ""); - break; - } - ret = convert_string_talloc(ndr, chset, CH_UNIX, - ndr->data+ndr->offset, - (len1 + c_len_term)*byte_mul, - (void **)&as); - if (ret == -1) { - return ndr_pull_error(ndr, NDR_ERR_CHARCNV, - "Bad character conversion"); - } - NDR_CHECK(ndr_pull_advance(ndr, (len1 + c_len_term)*byte_mul)); - - /* this is a way of detecting if a string is sent with the wrong - termination */ - if (ndr->flags & LIBNDR_FLAG_STR_NOTERM) { - if (strlen(as) < (len1 + c_len_term)) { - DEBUG(6,("short string '%s'\n", as)); - } - } else { - if (strlen(as) == (len1 + c_len_term)) { - DEBUG(6,("long string '%s'\n", as)); - } - } - *s = as; - break; - - case LIBNDR_FLAG_STR_LEN4: - case LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_NOTERM: - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &ofs)); - if (ofs != 0) { - return ndr_pull_error(ndr, NDR_ERR_STRING, "non-zero array offset with string flags 0x%x\n", - ndr->flags & LIBNDR_STRING_FLAGS); - } - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &len1)); - NDR_PULL_NEED_BYTES(ndr, (len1 + c_len_term)*byte_mul); - if (len1 == 0) { - *s = talloc_strdup(ndr, ""); - break; - } - ret = convert_string_talloc(ndr, chset, CH_UNIX, - ndr->data+ndr->offset, - (len1 + c_len_term)*byte_mul, - (void **)&as); - if (ret == -1) { - return ndr_pull_error(ndr, NDR_ERR_CHARCNV, - "Bad character conversion"); - } - NDR_CHECK(ndr_pull_advance(ndr, (len1 + c_len_term)*byte_mul)); - - /* this is a way of detecting if a string is sent with the wrong - termination */ - if (ndr->flags & LIBNDR_FLAG_STR_NOTERM) { - if (strlen(as) < (len1 + c_len_term)) { - DEBUG(6,("short string '%s'\n", as)); - } - } else { - if (strlen(as) == (len1 + c_len_term)) { - DEBUG(6,("long string '%s'\n", as)); - } - } - *s = as; - break; - - - case LIBNDR_FLAG_STR_SIZE2: - case LIBNDR_FLAG_STR_SIZE2|LIBNDR_FLAG_STR_NOTERM: - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &len3)); - NDR_PULL_NEED_BYTES(ndr, (len3 + c_len_term)*byte_mul); - if (len3 == 0) { - *s = talloc_strdup(ndr, ""); - break; - } - ret = convert_string_talloc(ndr, chset, CH_UNIX, - ndr->data+ndr->offset, - (len3 + c_len_term)*byte_mul, - (void **)&as); - if (ret == -1) { - return ndr_pull_error(ndr, NDR_ERR_CHARCNV, - "Bad character conversion"); - } - NDR_CHECK(ndr_pull_advance(ndr, (len3 + c_len_term)*byte_mul)); - - /* this is a way of detecting if a string is sent with the wrong - termination */ - if (ndr->flags & LIBNDR_FLAG_STR_NOTERM) { - if (strlen(as) < (len3 + c_len_term)) { - DEBUG(6,("short string '%s'\n", as)); - } - } else { - if (strlen(as) == (len3 + c_len_term)) { - DEBUG(6,("long string '%s'\n", as)); - } - } - *s = as; - break; - - case LIBNDR_FLAG_STR_SIZE2|LIBNDR_FLAG_STR_NOTERM|LIBNDR_FLAG_STR_BYTESIZE: - NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &len3)); - NDR_PULL_NEED_BYTES(ndr, len3); - if (len3 == 0) { - *s = talloc_strdup(ndr, ""); - break; - } - ret = convert_string_talloc(ndr, chset, CH_UNIX, - ndr->data+ndr->offset, - len3, - (void **)&as); - if (ret == -1) { - return ndr_pull_error(ndr, NDR_ERR_CHARCNV, - "Bad character conversion"); - } - NDR_CHECK(ndr_pull_advance(ndr, len3)); - *s = as; - break; - - case LIBNDR_FLAG_STR_NULLTERM: - if (byte_mul == 1) { - len1 = ascii_len_n((const char *)(ndr->data+ndr->offset), ndr->data_size - ndr->offset); - } else { - len1 = utf16_len_n(ndr->data+ndr->offset, ndr->data_size - ndr->offset); - } - ret = convert_string_talloc(ndr, chset, CH_UNIX, - ndr->data+ndr->offset, - len1, - (void **)&as); - if (ret == -1) { - return ndr_pull_error(ndr, NDR_ERR_CHARCNV, - "Bad character conversion"); - } - NDR_CHECK(ndr_pull_advance(ndr, len1)); - *s = as; - break; - - case LIBNDR_FLAG_STR_FIXLEN15: - case LIBNDR_FLAG_STR_FIXLEN32: - len1 = (flags & LIBNDR_FLAG_STR_FIXLEN32)?32:15; - NDR_PULL_NEED_BYTES(ndr, len1*byte_mul); - ret = convert_string_talloc(ndr, chset, CH_UNIX, - ndr->data+ndr->offset, - len1*byte_mul, - (void **)&as); - if (ret == -1) { - return ndr_pull_error(ndr, NDR_ERR_CHARCNV, - "Bad character conversion"); - } - NDR_CHECK(ndr_pull_advance(ndr, len1*byte_mul)); - *s = as; - break; - - default: - return ndr_pull_error(ndr, NDR_ERR_STRING, "Bad string flags 0x%x\n", - ndr->flags & LIBNDR_STRING_FLAGS); - } - - return NT_STATUS_OK; -} - - -/* - push a general string onto the wire -*/ -NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) -{ - ssize_t s_len, c_len, d_len; - int ret; - int chset = CH_UTF16; - unsigned flags = ndr->flags; - unsigned byte_mul = 2; - unsigned c_len_term = 1; - - if (!(ndr_flags & NDR_SCALARS)) { - return NT_STATUS_OK; - } - - if (NDR_BE(ndr)) { - chset = CH_UTF16BE; - } - - s_len = s?strlen(s):0; - c_len = s?strlen_m(s):0; - - if (flags & LIBNDR_FLAG_STR_ASCII) { - chset = CH_DOS; - byte_mul = 1; - flags &= ~LIBNDR_FLAG_STR_ASCII; - } - - if (flags & LIBNDR_FLAG_STR_UTF8) { - chset = CH_UTF8; - byte_mul = 1; - flags &= ~LIBNDR_FLAG_STR_UTF8; - } - - flags &= ~LIBNDR_FLAG_STR_CONFORMANT; - - if (flags & LIBNDR_FLAG_STR_CHARLEN) { - c_len_term = 0; - flags &= ~LIBNDR_FLAG_STR_CHARLEN; - } - - switch (flags & LIBNDR_STRING_FLAGS) { - case LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4: - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, c_len+c_len_term)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, c_len+c_len_term)); - NDR_PUSH_NEED_BYTES(ndr, byte_mul*(c_len+1)); - ret = convert_string(CH_UNIX, chset, - s, s_len+1, - ndr->data+ndr->offset, - byte_mul*(c_len+1)); - if (ret == -1) { - return ndr_push_error(ndr, NDR_ERR_CHARCNV, - "Bad character conversion"); - } - ndr->offset += byte_mul*(c_len+1); - break; - - case LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_NOTERM: - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, c_len)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, c_len)); - NDR_PUSH_NEED_BYTES(ndr, c_len*byte_mul); - ret = convert_string(CH_UNIX, chset, - s, s_len, - ndr->data+ndr->offset, c_len*byte_mul); - if (ret == -1) { - return ndr_push_error(ndr, NDR_ERR_CHARCNV, - "Bad character conversion"); - } - ndr->offset += c_len*byte_mul; - break; - - case LIBNDR_FLAG_STR_LEN4: - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, c_len + c_len_term)); - NDR_PUSH_NEED_BYTES(ndr, byte_mul*(c_len+1)); - ret = convert_string(CH_UNIX, chset, - s, s_len + 1, - ndr->data+ndr->offset, byte_mul*(c_len+1)); - if (ret == -1) { - return ndr_push_error(ndr, NDR_ERR_CHARCNV, - "Bad character conversion"); - } - ndr->offset += byte_mul*(c_len+1); - break; - - case LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_NOTERM: - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, c_len)); - NDR_PUSH_NEED_BYTES(ndr, byte_mul*c_len); - ret = convert_string(CH_UNIX, chset, - s, s_len, - ndr->data+ndr->offset, byte_mul*c_len); - if (ret == -1) { - return ndr_push_error(ndr, NDR_ERR_CHARCNV, - "Bad character conversion"); - } - ndr->offset += byte_mul*c_len; - break; - - case LIBNDR_FLAG_STR_SIZE4: - NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, c_len + c_len_term)); - NDR_PUSH_NEED_BYTES(ndr, byte_mul*(c_len+1)); - ret = convert_string(CH_UNIX, chset, - s, s_len + 1, - ndr->data+ndr->offset, byte_mul*(c_len+1)); - if (ret == -1) { - return ndr_push_error(ndr, NDR_ERR_CHARCNV, - "Bad character conversion"); - } - ndr->offset += byte_mul*(c_len+1); - break; - - case LIBNDR_FLAG_STR_SIZE2: - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, c_len + c_len_term)); - NDR_PUSH_NEED_BYTES(ndr, byte_mul*(c_len+1)); - ret = convert_string(CH_UNIX, chset, - s, s_len + 1, - ndr->data+ndr->offset, byte_mul*(c_len+1)); - if (ret == -1) { - return ndr_push_error(ndr, NDR_ERR_CHARCNV, - "Bad character conversion"); - } - ndr->offset += byte_mul*(c_len+1); - break; - - case LIBNDR_FLAG_STR_NULLTERM: - NDR_PUSH_NEED_BYTES(ndr, byte_mul*(c_len+1)); - ret = convert_string(CH_UNIX, chset, - s, s_len+1, - ndr->data+ndr->offset, byte_mul*(c_len+1)); - if (ret == -1) { - return ndr_push_error(ndr, NDR_ERR_CHARCNV, - "Bad character conversion"); - } - ndr->offset += byte_mul*(c_len+1); - break; - - case LIBNDR_FLAG_STR_SIZE2|LIBNDR_FLAG_STR_NOTERM|LIBNDR_FLAG_STR_BYTESIZE: - NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, c_len*byte_mul)); - NDR_PUSH_NEED_BYTES(ndr, c_len*byte_mul); - ret = convert_string(CH_UNIX, chset, - s, s_len, - ndr->data+ndr->offset, c_len*byte_mul); - if (ret == -1) { - return ndr_push_error(ndr, NDR_ERR_CHARCNV, - "Bad character conversion"); - } - ndr->offset += c_len*byte_mul; - break; - - case LIBNDR_FLAG_STR_FIXLEN15: - case LIBNDR_FLAG_STR_FIXLEN32: - d_len = (flags & LIBNDR_FLAG_STR_FIXLEN32)?32:15; - NDR_PUSH_NEED_BYTES(ndr, byte_mul*d_len); - ret = convert_string(CH_UNIX, chset, - s, s_len, - ndr->data+ndr->offset, byte_mul*d_len); - if (ret == -1) { - return ndr_push_error(ndr, NDR_ERR_CHARCNV, - "Bad character conversion"); - } - ndr->offset += byte_mul*d_len; - break; - - default: - return ndr_push_error(ndr, NDR_ERR_STRING, "Bad string flags 0x%x\n", - ndr->flags & LIBNDR_STRING_FLAGS); - } - - return NT_STATUS_OK; -} - -/* - push a general string onto the wire -*/ -size_t ndr_string_array_size(struct ndr_push *ndr, const char *s) -{ - size_t c_len; - unsigned flags = ndr->flags; - unsigned byte_mul = 2; - unsigned c_len_term = 1; - - if (flags & LIBNDR_FLAG_STR_FIXLEN32) { - return 32; - } - if (flags & LIBNDR_FLAG_STR_FIXLEN15) { - return 15; - } - - c_len = s?strlen_m(s):0; - - if (flags & (LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_UTF8)) { - byte_mul = 1; - } - - if (flags & LIBNDR_FLAG_STR_NOTERM) { - c_len_term = 0; - } - - c_len = c_len + c_len_term; - - if (flags & LIBNDR_FLAG_STR_BYTESIZE) { - c_len = c_len * byte_mul; - } - - return c_len; -} - /* push a NTTIME @@ -1246,15 +786,6 @@ void ndr_print_ptr(struct ndr_print *ndr, const char *name, const void *p) } } -void ndr_print_string(struct ndr_print *ndr, const char *name, const char *s) -{ - if (s) { - ndr->print(ndr, "%-25s: '%s'", name, s); - } else { - ndr->print(ndr, "%-25s: NULL", name); - } -} - void ndr_print_NTTIME(struct ndr_print *ndr, const char *name, NTTIME t) { ndr->print(ndr, "%-25s: %s", name, nt_time_string(ndr, t)); @@ -1456,10 +987,3 @@ uint32_t ndr_size_DATA_BLOB(int ret, const DATA_BLOB *data, int flags) { return ret + data->length; } - -uint32_t ndr_size_string(int ret, const char * const* string, int flags) -{ - /* FIXME: Is this correct for all strings ? */ - if(!(*string)) return ret; - return ret+strlen(*string)+1; -} -- cgit From d70232a747eee67624ea8798e0459674031ead1c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 2 May 2005 14:53:19 +0000 Subject: r6574: send a value for embedded ref pointers, (this fixes the doublepointer test against w2k3) but we accept zero pointers on the receive side, because it's used in DRSUAPI metze (This used to be commit 748ab5449bcc5b47f5ceaa83277bf8084c44ec56) --- source4/librpc/ndr/ndr_basic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 31a1c816b4..a33378dd1b 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -577,7 +577,7 @@ NTSTATUS ndr_push_ref_ptr(struct ndr_push *ndr, const void *p) if (p == NULL) { return NT_STATUS_INVALID_PARAMETER_MIX; } - return ndr_push_uint32(ndr, NDR_SCALARS, 0); + return ndr_push_uint32(ndr, NDR_SCALARS, 0xAEF1AEF1); } -- cgit From 53067ce37fc6056961768411062414e9074da2ab Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 5 Jul 2005 06:17:47 +0000 Subject: r8157: add the algorithm for unique pointers that w2k3 uses. this is ifdef'ed out currently because we use 'unique' pointers in the epmapper pipe, where we should use 'ptr' full pointers. metze (This used to be commit ccc9d9267a60287eff1fb26132aa7cae3b39dcee) --- source4/librpc/ndr/ndr_basic.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index a33378dd1b..0a268ac6c9 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -563,8 +563,14 @@ NTSTATUS ndr_push_unique_ptr(struct ndr_push *ndr, const void *p) { uint32_t ptr = 0; if (p) { +#if 0 + ptr = ndr->ptr_count * 4; + ptr |= 0x00020000; + ndr->ptr_count++; +#else ndr->ptr_count++; ptr = ndr->ptr_count; +#endif } return ndr_push_uint32(ndr, NDR_SCALARS, ptr); } -- cgit From 4a993c5241c26bbd86f3aba830cb5a5a7a2a6ae7 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 5 Jul 2005 12:09:33 +0000 Subject: r8167: - use the same algorithm than w2k3 for 'unique' pointer values - add a new 'sptr' (simple-full) pointer type to simulate what we need to support pipes like epmapper and mgmt that uses 'ptr' full pointer in their spec - I runned make test and test_w2k3.sh with this, all fine does we have any other pipe using 'unique' pointer where we need 'ptr'? btw: jelmer, what does 'ignore' pointers do? they are allowed in pidl but not implemented! metze (This used to be commit d19068bfb2e3ff5d88bc3b76d5cef93417c7f218) --- source4/librpc/ndr/ndr_basic.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 0a268ac6c9..8b473724dc 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -128,7 +128,7 @@ NTSTATUS ndr_pull_uint32(struct ndr_pull *ndr, int ndr_flags, uint32_t *v) /* parse a pointer referent identifier */ -NTSTATUS ndr_pull_unique_ptr(struct ndr_pull *ndr, uint32_t *v) +NTSTATUS ndr_pull_generic_ptr(struct ndr_pull *ndr, uint32_t *v) { NTSTATUS status; status = ndr_pull_uint32(ndr, NDR_SCALARS, v); @@ -563,14 +563,22 @@ NTSTATUS ndr_push_unique_ptr(struct ndr_push *ndr, const void *p) { uint32_t ptr = 0; if (p) { -#if 0 ptr = ndr->ptr_count * 4; ptr |= 0x00020000; ndr->ptr_count++; -#else + } + return ndr_push_uint32(ndr, NDR_SCALARS, ptr); +} + +/* + push a 'simple' full non-zero value if a pointer is non-NULL, otherwise 0 +*/ +NTSTATUS ndr_push_sptr_ptr(struct ndr_push *ndr, const void *p) +{ + uint32_t ptr = 0; + if (p) { ndr->ptr_count++; ptr = ndr->ptr_count; -#endif } return ndr_push_uint32(ndr, NDR_SCALARS, ptr); } -- cgit From e835621799647ee70630b389fb53d15b15d68355 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 17 Jul 2005 09:20:52 +0000 Subject: r8520: fixed a pile of warnings from the build farm gcc -Wall output on S390. This is an attempt to avoid the panic we're seeing in the automatic builds. The main fixes are: - assumptions that sizeof(size_t) == sizeof(int), mostly in printf formats - use of NULL format statements to perform dn searches. - assumption that sizeof() returns an int (This used to be commit a58ea6b3854973b694d2b1e22323ed7eb00e3a3f) --- source4/librpc/ndr/ndr_basic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 8b473724dc..5046b860a3 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -46,7 +46,7 @@ void ndr_check_padding(struct ndr_pull *ndr, size_t n) } } if (ioffset;idata[i])); } -- cgit From d99d06d954321331f8558da8604e1fd4dd956d13 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 19 Jul 2005 19:00:22 +0000 Subject: r8612: Parse::Pidl::NDR: Values that are deferred but don't contain deferred data don't need NDR_BUFFERS Parse::Pidl::Samba::NDR::Parser: Only use manually written array access functions when the array functions are faster then the autogenerated ones. Makes ndr_basic.c a bit shorter. (This used to be commit cad40815dcfb7cdcab13bd0cd204ef8711605ef3) --- source4/librpc/ndr/ndr_basic.c | 192 ----------------------------------------- 1 file changed, 192 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 5046b860a3..efff2dbc5f 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -262,66 +262,6 @@ NTSTATUS ndr_pull_array_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *data return ndr_pull_bytes(ndr, data, n); } -/* - pull an array of uint16 -*/ -NTSTATUS ndr_pull_array_uint16(struct ndr_pull *ndr, int ndr_flags, uint16_t *data, uint32_t n) -{ - uint32_t i; - if (!(ndr_flags & NDR_SCALARS)) { - return NT_STATUS_OK; - } - for (i=0;iprint(ndr, "UNKNOWN LEVEL %u", level); } -void ndr_print_array_WERROR(struct ndr_print *ndr, const char *name, - const WERROR *data, uint32_t count) -{ - int i; - - ndr->print(ndr, "%s: ARRAY(%d)", name, count); - ndr->depth++; - for (i=0;idepth--; -} - -void ndr_print_array_hyper(struct ndr_print *ndr, const char *name, - const uint64_t *data, uint32_t count) -{ - int i; - - ndr->print(ndr, "%s: ARRAY(%d)", name, count); - ndr->depth++; - for (i=0;idepth--; -} - -void ndr_print_array_uint32(struct ndr_print *ndr, const char *name, - const uint32_t *data, uint32_t count) -{ - int i; - - ndr->print(ndr, "%s: ARRAY(%d)", name, count); - ndr->depth++; - for (i=0;idepth--; -} - -void ndr_print_array_uint16(struct ndr_print *ndr, const char *name, - const uint16_t *data, uint32_t count) -{ - int i; - - ndr->print(ndr, "%s: ARRAY(%d)", name, count); - ndr->depth++; - for (i=0;idepth--; -} - void ndr_print_array_uint8(struct ndr_print *ndr, const char *name, const uint8_t *data, uint32_t count) { -- cgit From efa30b073fb1121f61034d9ad60d0a76f14b3cd9 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 20 Sep 2005 07:56:54 +0000 Subject: r10339: fix ndr_push_udlongr metze (This used to be commit a34d0771ce60d4c590c8bc14449cc23d31a6dd2c) --- source4/librpc/ndr/ndr_basic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index efff2dbc5f..4d3ac2c774 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -352,8 +352,8 @@ NTSTATUS ndr_push_udlongr(struct ndr_push *ndr, int ndr_flags, uint64_t v) { NDR_PUSH_ALIGN(ndr, 4); NDR_PUSH_NEED_BYTES(ndr, 8); - NDR_SIVAL(ndr, ndr->offset+4, (v>>32)); - NDR_SIVAL(ndr, ndr->offset, (v & 0xFFFFFFFF)); + NDR_SIVAL(ndr, ndr->offset, (v>>32)); + NDR_SIVAL(ndr, ndr->offset+4, (v & 0xFFFFFFFF)); ndr->offset += 8; return NT_STATUS_OK; } -- cgit From b7545608ad0cbcc017219cd4b2d699a25500c5f1 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 20 Sep 2005 11:39:40 +0000 Subject: r10346: here are only real ip-addresses valid, prevent dns lookups, when the input is invalid metze (This used to be commit 1083204c1f89d9b918015113b6cc2ea423372fe0) --- source4/librpc/ndr/ndr_basic.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 4d3ac2c774..e559ea8ff6 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -569,7 +569,9 @@ NTSTATUS ndr_pull_ipv4address(struct ndr_pull *ndr, int ndr_flags, const char ** */ NTSTATUS ndr_push_ipv4address(struct ndr_push *ndr, int ndr_flags, const char *address) { - uint32_t addr = interpret_addr(address); + uint32_t addr; + if (!is_ipaddress(address)) return NT_STATUS_INVALID_PARAMETER_MIX; + addr = sys_inet_addr(address); NDR_CHECK(ndr_push_uint32(ndr, ndr_flags, htonl(addr))); return NT_STATUS_OK; } -- cgit From f3b412fbd6dd94d64eb6a63d88baef2816891c29 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 23 Sep 2005 00:38:22 +0000 Subject: r10438: Move portability functions to lib/replace/; replace now simply ensures that a given set of (working) POSIX functions are available (without prefixes to their names, etc). See lib/replace/README for a list. Functions that behave different from their POSIX specification (such as sys_select, sys_read, etc) have kept the sys_ prefix. (This used to be commit 29919a71059b29fa27a49b1f5b84bb8881de65fc) --- source4/librpc/ndr/ndr_basic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index e559ea8ff6..b3740c5e01 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -571,7 +571,7 @@ NTSTATUS ndr_push_ipv4address(struct ndr_push *ndr, int ndr_flags, const char *a { uint32_t addr; if (!is_ipaddress(address)) return NT_STATUS_INVALID_PARAMETER_MIX; - addr = sys_inet_addr(address); + addr = inet_addr(address); NDR_CHECK(ndr_push_uint32(ndr, ndr_flags, htonl(addr))); return NT_STATUS_OK; } -- cgit From f1c52270785285fcf68e2b22fbc83cbee38910fd Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 30 Sep 2005 01:49:32 +0000 Subject: r10637: use the correct memory context in the ndr_pull_* function to build the talloc hierachie correct metze (This used to be commit afd9dda5773d381550bdb061a8e345b33e1fc371) --- source4/librpc/ndr/ndr_basic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index b3740c5e01..23e686f76f 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -559,7 +559,7 @@ NTSTATUS ndr_pull_ipv4address(struct ndr_pull *ndr, int ndr_flags, const char ** struct ipv4_addr in; NDR_CHECK(ndr_pull_uint32(ndr, ndr_flags, &in.addr)); in.addr = htonl(in.addr); - *address = talloc_strdup(ndr, sys_inet_ntoa(in)); + *address = talloc_strdup(ndr->current_mem_ctx, sys_inet_ntoa(in)); NT_STATUS_HAVE_NO_MEMORY(*address); return NT_STATUS_OK; } @@ -802,7 +802,7 @@ NTSTATUS ndr_pull_DATA_BLOB(struct ndr_pull *ndr, int ndr_flags, DATA_BLOB *blob NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &length)); } NDR_PULL_NEED_BYTES(ndr, length); - *blob = data_blob_talloc(ndr, ndr->data+ndr->offset, length); + *blob = data_blob_talloc(ndr->current_mem_ctx, ndr->data+ndr->offset, length); ndr->offset += length; return NT_STATUS_OK; } -- cgit From b94fcbd306bbf758d26fb40c7c0a1b00ba6fe38d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 10 Oct 2005 11:47:23 +0000 Subject: r10868: make flag(NDR_PAHEX) possible to use and show the union level in hex metze (This used to be commit 7efb92adc057ad8a993eb9de66c3806608747104) --- source4/librpc/ndr/ndr_basic.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 23e686f76f..8f2cf49a1c 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -711,7 +711,11 @@ void ndr_print_time_t(struct ndr_print *ndr, const char *name, time_t t) void ndr_print_union(struct ndr_print *ndr, const char *name, int level, const char *type) { - ndr->print(ndr, "%-25s: union %s(case %d)", name, type, level); + if (ndr->flags & LIBNDR_PRINT_ARRAY_HEX) { + ndr->print(ndr, "%-25s: union %s(case 0x%X)", name, type, level); + } else { + ndr->print(ndr, "%-25s: union %s(case %d)", name, type, level); + } } void ndr_print_bad_level(struct ndr_print *ndr, const char *name, uint16_t level) -- cgit From 1598aaca9579f4e2ca9d1fd539693969a2319a4b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 11 Nov 2005 10:49:55 +0000 Subject: r11676: as tridge uses 0x%llx in his latest commits... try to use it every where and see how portable it is metze (This used to be commit 66a94de5ddd09df858a515555c01aa3d4f7d3e96) --- source4/librpc/ndr/ndr_basic.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 8f2cf49a1c..d76fa45ec3 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -649,10 +649,7 @@ void ndr_print_uint32(struct ndr_print *ndr, const char *name, uint32_t v) void ndr_print_udlong(struct ndr_print *ndr, const char *name, uint64_t v) { - ndr->print(ndr, "%-25s: 0x%08x%08x (%llu)", name, - (uint32_t)(v >> 32), - (uint32_t)(v & 0xFFFFFFFF), - v); + ndr->print(ndr, "%-25s: 0x%016llx (%llu)", name, v, v); } void ndr_print_udlongr(struct ndr_print *ndr, const char *name, uint64_t v) @@ -662,10 +659,7 @@ void ndr_print_udlongr(struct ndr_print *ndr, const char *name, uint64_t v) void ndr_print_dlong(struct ndr_print *ndr, const char *name, int64_t v) { - ndr->print(ndr, "%-25s: 0x%08x%08x (%lld)", name, - (uint32_t)(v >> 32), - (uint32_t)(v & 0xFFFFFFFF), - v); + ndr->print(ndr, "%-25s: 0x%016llx (%lld)", name, v, v); } void ndr_print_hyper(struct ndr_print *ndr, const char *name, uint64_t v) -- cgit From fd18ab334a5b9aea301f8c5ba33b380b7ef76038 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 30 Nov 2005 13:10:44 +0000 Subject: r11973: make it easier to find bugs metze (This used to be commit 247f90c28d845fd2224cb07ed30d3e8122ba5644) --- source4/librpc/ndr/ndr_basic.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index d76fa45ec3..f22e7989bf 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -570,7 +570,11 @@ NTSTATUS ndr_pull_ipv4address(struct ndr_pull *ndr, int ndr_flags, const char ** NTSTATUS ndr_push_ipv4address(struct ndr_push *ndr, int ndr_flags, const char *address) { uint32_t addr; - if (!is_ipaddress(address)) return NT_STATUS_INVALID_PARAMETER_MIX; + if (!is_ipaddress(address)) { + return ndr_push_error(ndr, NDR_ERR_IPV4ADDRESS, + "Invalid IPv4 address: '%s'", + address); + } addr = inet_addr(address); NDR_CHECK(ndr_push_uint32(ndr, ndr_flags, htonl(addr))); return NT_STATUS_OK; -- cgit From f4edfc21e5be94ef982caea1891b2305d7dfba85 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 2 Dec 2005 11:33:19 +0000 Subject: r12016: fixed a valgrind error (This used to be commit 482548031e69ba4bddac999ca9f2cb6ad8359953) --- source4/librpc/ndr/ndr_basic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index f22e7989bf..615119fad3 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -132,7 +132,7 @@ NTSTATUS ndr_pull_generic_ptr(struct ndr_pull *ndr, uint32_t *v) { NTSTATUS status; status = ndr_pull_uint32(ndr, NDR_SCALARS, v); - if (*v != 0) { + if (NT_STATUS_IS_OK(status) && *v != 0) { ndr->ptr_count++; } return status; -- cgit From e3e048630be2fbf20d580850e5673ad372bd34f0 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 28 Feb 2006 03:42:19 +0000 Subject: r13738: added support for a "pointer" type in pidl. This will be used in the opendb work that will be committed shortly. The pointer type assumes that pointers fit in 64 bits, which is probably OK on all our supported architectures. (This used to be commit d2a2057ea5af140ca88a9c305a38fc5dca9eaafd) --- source4/librpc/ndr/ndr_basic.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 615119fad3..8020c7da23 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -192,6 +192,19 @@ NTSTATUS ndr_pull_hyper(struct ndr_pull *ndr, int ndr_flags, uint64_t *v) return ndr_pull_udlong(ndr, ndr_flags, v); } +/* + parse a pointer +*/ +NTSTATUS ndr_pull_pointer(struct ndr_pull *ndr, int ndr_flags, void* *v) +{ + uint64_t h; + NTSTATUS status; + NDR_PULL_ALIGN(ndr, 8); + status = ndr_pull_udlong(ndr, ndr_flags, &h); + *v = (void *)((intptr_t)h); + return status; +} + /* pull a NTSTATUS */ @@ -375,6 +388,15 @@ NTSTATUS ndr_push_hyper(struct ndr_push *ndr, int ndr_flags, uint64_t v) return ndr_push_udlong(ndr, NDR_SCALARS, v); } +/* + push a pointer +*/ +NTSTATUS ndr_push_pointer(struct ndr_push *ndr, int ndr_flags, void* v) +{ + NDR_PUSH_ALIGN(ndr, 8); + return ndr_push_udlong(ndr, NDR_SCALARS, (intptr_t)v); +} + NTSTATUS ndr_push_align(struct ndr_push *ndr, size_t size) { NDR_PUSH_ALIGN(ndr, size); @@ -671,6 +693,11 @@ void ndr_print_hyper(struct ndr_print *ndr, const char *name, uint64_t v) ndr_print_dlong(ndr, name, v); } +void ndr_print_pointer(struct ndr_print *ndr, const char *name, void *v) +{ + ndr->print(ndr, "%-25s: %p", name, v); +} + void ndr_print_ptr(struct ndr_print *ndr, const char *name, const void *p) { if (p) { -- cgit From 4be369984895ffb5afc5bf9d56ef19d944513eb3 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 28 Feb 2006 04:02:26 +0000 Subject: r13741: make the pointer type in pidl handle any size pointer, just in case we have a 128 bit machine out there somewhere (This used to be commit 4a1b7580a7ea5db7d10c8ee6a5b3950313b7d273) --- source4/librpc/ndr/ndr_basic.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 8020c7da23..ccc1c8a016 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -197,12 +197,13 @@ NTSTATUS ndr_pull_hyper(struct ndr_pull *ndr, int ndr_flags, uint64_t *v) */ NTSTATUS ndr_pull_pointer(struct ndr_pull *ndr, int ndr_flags, void* *v) { - uint64_t h; - NTSTATUS status; - NDR_PULL_ALIGN(ndr, 8); - status = ndr_pull_udlong(ndr, ndr_flags, &h); - *v = (void *)((intptr_t)h); - return status; + intptr_t h; + NDR_PULL_ALIGN(ndr, sizeof(h)); + NDR_PULL_NEED_BYTES(ndr, sizeof(h)); + memcpy(&h, ndr->data+ndr->offset, sizeof(h)); + ndr->offset += sizeof(h); + *v = (void *)h; + return NT_STATUS_OK; } /* @@ -393,8 +394,12 @@ NTSTATUS ndr_push_hyper(struct ndr_push *ndr, int ndr_flags, uint64_t v) */ NTSTATUS ndr_push_pointer(struct ndr_push *ndr, int ndr_flags, void* v) { - NDR_PUSH_ALIGN(ndr, 8); - return ndr_push_udlong(ndr, NDR_SCALARS, (intptr_t)v); + intptr_t h = (intptr_t)v; + NDR_PUSH_ALIGN(ndr, sizeof(h)); + NDR_PUSH_NEED_BYTES(ndr, sizeof(h)); + memcpy(ndr->data+ndr->offset, &h, sizeof(h)); + ndr->offset += sizeof(h); + return NT_STATUS_OK; } NTSTATUS ndr_push_align(struct ndr_push *ndr, size_t size) -- cgit From af30a32b6924b0f2b701186e435defbca2ebd1aa Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 5 Mar 2006 17:15:19 +0000 Subject: r13840: Mark some functions as public. (This used to be commit 9a188eb1f48a50d92a67a4fc2b3899b90074059a) --- source4/librpc/ndr/ndr_basic.c | 160 ++++++++++++++++++++--------------------- 1 file changed, 80 insertions(+), 80 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index ccc1c8a016..000a0c3498 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -36,7 +36,7 @@ these could also indicate that real structure elements have been mistaken for padding in the IDL */ -void ndr_check_padding(struct ndr_pull *ndr, size_t n) +_PUBLIC_ void ndr_check_padding(struct ndr_pull *ndr, size_t n) { size_t ofs2 = (ndr->offset + (n-1)) & ~(n-1); int i; @@ -58,7 +58,7 @@ void ndr_check_padding(struct ndr_pull *ndr, size_t n) /* parse a int8_t */ -NTSTATUS ndr_pull_int8(struct ndr_pull *ndr, int ndr_flags, int8_t *v) +_PUBLIC_ NTSTATUS ndr_pull_int8(struct ndr_pull *ndr, int ndr_flags, int8_t *v) { NDR_PULL_NEED_BYTES(ndr, 1); *v = (int8_t)CVAL(ndr->data, ndr->offset); @@ -69,7 +69,7 @@ NTSTATUS ndr_pull_int8(struct ndr_pull *ndr, int ndr_flags, int8_t *v) /* parse a uint8_t */ -NTSTATUS ndr_pull_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *v) +_PUBLIC_ NTSTATUS ndr_pull_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *v) { NDR_PULL_NEED_BYTES(ndr, 1); *v = CVAL(ndr->data, ndr->offset); @@ -80,7 +80,7 @@ NTSTATUS ndr_pull_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *v) /* parse a int16_t */ -NTSTATUS ndr_pull_int16(struct ndr_pull *ndr, int ndr_flags, int16_t *v) +_PUBLIC_ NTSTATUS ndr_pull_int16(struct ndr_pull *ndr, int ndr_flags, int16_t *v) { NDR_PULL_ALIGN(ndr, 2); NDR_PULL_NEED_BYTES(ndr, 2); @@ -92,7 +92,7 @@ NTSTATUS ndr_pull_int16(struct ndr_pull *ndr, int ndr_flags, int16_t *v) /* parse a uint16_t */ -NTSTATUS ndr_pull_uint16(struct ndr_pull *ndr, int ndr_flags, uint16_t *v) +_PUBLIC_ NTSTATUS ndr_pull_uint16(struct ndr_pull *ndr, int ndr_flags, uint16_t *v) { NDR_PULL_ALIGN(ndr, 2); NDR_PULL_NEED_BYTES(ndr, 2); @@ -104,7 +104,7 @@ NTSTATUS ndr_pull_uint16(struct ndr_pull *ndr, int ndr_flags, uint16_t *v) /* parse a int32_t */ -NTSTATUS ndr_pull_int32(struct ndr_pull *ndr, int ndr_flags, int32_t *v) +_PUBLIC_ NTSTATUS ndr_pull_int32(struct ndr_pull *ndr, int ndr_flags, int32_t *v) { NDR_PULL_ALIGN(ndr, 4); NDR_PULL_NEED_BYTES(ndr, 4); @@ -116,7 +116,7 @@ NTSTATUS ndr_pull_int32(struct ndr_pull *ndr, int ndr_flags, int32_t *v) /* parse a uint32_t */ -NTSTATUS ndr_pull_uint32(struct ndr_pull *ndr, int ndr_flags, uint32_t *v) +_PUBLIC_ NTSTATUS ndr_pull_uint32(struct ndr_pull *ndr, int ndr_flags, uint32_t *v) { NDR_PULL_ALIGN(ndr, 4); NDR_PULL_NEED_BYTES(ndr, 4); @@ -128,7 +128,7 @@ NTSTATUS ndr_pull_uint32(struct ndr_pull *ndr, int ndr_flags, uint32_t *v) /* parse a pointer referent identifier */ -NTSTATUS ndr_pull_generic_ptr(struct ndr_pull *ndr, uint32_t *v) +_PUBLIC_ NTSTATUS ndr_pull_generic_ptr(struct ndr_pull *ndr, uint32_t *v) { NTSTATUS status; status = ndr_pull_uint32(ndr, NDR_SCALARS, v); @@ -141,7 +141,7 @@ NTSTATUS ndr_pull_generic_ptr(struct ndr_pull *ndr, uint32_t *v) /* parse a ref pointer referent identifier */ -NTSTATUS ndr_pull_ref_ptr(struct ndr_pull *ndr, uint32_t *v) +_PUBLIC_ NTSTATUS ndr_pull_ref_ptr(struct ndr_pull *ndr, uint32_t *v) { NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, v)); /* ref pointers always point to data */ @@ -152,7 +152,7 @@ NTSTATUS ndr_pull_ref_ptr(struct ndr_pull *ndr, uint32_t *v) /* parse a udlong */ -NTSTATUS ndr_pull_udlong(struct ndr_pull *ndr, int ndr_flags, uint64_t *v) +_PUBLIC_ NTSTATUS ndr_pull_udlong(struct ndr_pull *ndr, int ndr_flags, uint64_t *v) { NDR_PULL_ALIGN(ndr, 4); NDR_PULL_NEED_BYTES(ndr, 8); @@ -165,7 +165,7 @@ NTSTATUS ndr_pull_udlong(struct ndr_pull *ndr, int ndr_flags, uint64_t *v) /* parse a udlongr */ -NTSTATUS ndr_pull_udlongr(struct ndr_pull *ndr, int ndr_flags, uint64_t *v) +_PUBLIC_ NTSTATUS ndr_pull_udlongr(struct ndr_pull *ndr, int ndr_flags, uint64_t *v) { NDR_PULL_ALIGN(ndr, 4); NDR_PULL_NEED_BYTES(ndr, 8); @@ -178,7 +178,7 @@ NTSTATUS ndr_pull_udlongr(struct ndr_pull *ndr, int ndr_flags, uint64_t *v) /* parse a dlong */ -NTSTATUS ndr_pull_dlong(struct ndr_pull *ndr, int ndr_flags, int64_t *v) +_PUBLIC_ NTSTATUS ndr_pull_dlong(struct ndr_pull *ndr, int ndr_flags, int64_t *v) { return ndr_pull_udlong(ndr, ndr_flags, (uint64_t *)v); } @@ -186,7 +186,7 @@ NTSTATUS ndr_pull_dlong(struct ndr_pull *ndr, int ndr_flags, int64_t *v) /* parse a hyper */ -NTSTATUS ndr_pull_hyper(struct ndr_pull *ndr, int ndr_flags, uint64_t *v) +_PUBLIC_ NTSTATUS ndr_pull_hyper(struct ndr_pull *ndr, int ndr_flags, uint64_t *v) { NDR_PULL_ALIGN(ndr, 8); return ndr_pull_udlong(ndr, ndr_flags, v); @@ -195,7 +195,7 @@ NTSTATUS ndr_pull_hyper(struct ndr_pull *ndr, int ndr_flags, uint64_t *v) /* parse a pointer */ -NTSTATUS ndr_pull_pointer(struct ndr_pull *ndr, int ndr_flags, void* *v) +_PUBLIC_ NTSTATUS ndr_pull_pointer(struct ndr_pull *ndr, int ndr_flags, void* *v) { intptr_t h; NDR_PULL_ALIGN(ndr, sizeof(h)); @@ -209,7 +209,7 @@ NTSTATUS ndr_pull_pointer(struct ndr_pull *ndr, int ndr_flags, void* *v) /* pull a NTSTATUS */ -NTSTATUS ndr_pull_NTSTATUS(struct ndr_pull *ndr, int ndr_flags, NTSTATUS *status) +_PUBLIC_ NTSTATUS ndr_pull_NTSTATUS(struct ndr_pull *ndr, int ndr_flags, NTSTATUS *status) { uint32_t v; NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v)); @@ -220,12 +220,12 @@ NTSTATUS ndr_pull_NTSTATUS(struct ndr_pull *ndr, int ndr_flags, NTSTATUS *status /* push a NTSTATUS */ -NTSTATUS ndr_push_NTSTATUS(struct ndr_push *ndr, int ndr_flags, NTSTATUS status) +_PUBLIC_ NTSTATUS ndr_push_NTSTATUS(struct ndr_push *ndr, int ndr_flags, NTSTATUS status) { return ndr_push_uint32(ndr, ndr_flags, NT_STATUS_V(status)); } -void ndr_print_NTSTATUS(struct ndr_print *ndr, const char *name, NTSTATUS r) +_PUBLIC_ void ndr_print_NTSTATUS(struct ndr_print *ndr, const char *name, NTSTATUS r) { ndr->print(ndr, "%-25s: %s", name, nt_errstr(r)); } @@ -233,7 +233,7 @@ void ndr_print_NTSTATUS(struct ndr_print *ndr, const char *name, NTSTATUS r) /* pull a WERROR */ -NTSTATUS ndr_pull_WERROR(struct ndr_pull *ndr, int ndr_flags, WERROR *status) +_PUBLIC_ NTSTATUS ndr_pull_WERROR(struct ndr_pull *ndr, int ndr_flags, WERROR *status) { uint32_t v; NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v)); @@ -244,12 +244,12 @@ NTSTATUS ndr_pull_WERROR(struct ndr_pull *ndr, int ndr_flags, WERROR *status) /* push a WERROR */ -NTSTATUS ndr_push_WERROR(struct ndr_push *ndr, int ndr_flags, WERROR status) +_PUBLIC_ NTSTATUS ndr_push_WERROR(struct ndr_push *ndr, int ndr_flags, WERROR status) { return ndr_push_uint32(ndr, NDR_SCALARS, W_ERROR_V(status)); } -void ndr_print_WERROR(struct ndr_print *ndr, const char *name, WERROR r) +_PUBLIC_ void ndr_print_WERROR(struct ndr_print *ndr, const char *name, WERROR r) { ndr->print(ndr, "%-25s: %s", name, win_errstr(r)); } @@ -257,7 +257,7 @@ void ndr_print_WERROR(struct ndr_print *ndr, const char *name, WERROR r) /* parse a set of bytes */ -NTSTATUS ndr_pull_bytes(struct ndr_pull *ndr, uint8_t *data, uint32_t n) +_PUBLIC_ NTSTATUS ndr_pull_bytes(struct ndr_pull *ndr, uint8_t *data, uint32_t n) { NDR_PULL_NEED_BYTES(ndr, n); memcpy(data, ndr->data + ndr->offset, n); @@ -268,7 +268,7 @@ NTSTATUS ndr_pull_bytes(struct ndr_pull *ndr, uint8_t *data, uint32_t n) /* pull an array of uint8 */ -NTSTATUS ndr_pull_array_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *data, uint32_t n) +_PUBLIC_ NTSTATUS ndr_pull_array_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *data, uint32_t n) { if (!(ndr_flags & NDR_SCALARS)) { return NT_STATUS_OK; @@ -279,7 +279,7 @@ NTSTATUS ndr_pull_array_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *data /* push a int8_t */ -NTSTATUS ndr_push_int8(struct ndr_push *ndr, int ndr_flags, int8_t v) +_PUBLIC_ NTSTATUS ndr_push_int8(struct ndr_push *ndr, int ndr_flags, int8_t v) { NDR_PUSH_NEED_BYTES(ndr, 1); SCVAL(ndr->data, ndr->offset, (uint8_t)v); @@ -290,7 +290,7 @@ NTSTATUS ndr_push_int8(struct ndr_push *ndr, int ndr_flags, int8_t v) /* push a uint8_t */ -NTSTATUS ndr_push_uint8(struct ndr_push *ndr, int ndr_flags, uint8_t v) +_PUBLIC_ NTSTATUS ndr_push_uint8(struct ndr_push *ndr, int ndr_flags, uint8_t v) { NDR_PUSH_NEED_BYTES(ndr, 1); SCVAL(ndr->data, ndr->offset, v); @@ -301,7 +301,7 @@ NTSTATUS ndr_push_uint8(struct ndr_push *ndr, int ndr_flags, uint8_t v) /* push a int16_t */ -NTSTATUS ndr_push_int16(struct ndr_push *ndr, int ndr_flags, int16_t v) +_PUBLIC_ NTSTATUS ndr_push_int16(struct ndr_push *ndr, int ndr_flags, int16_t v) { NDR_PUSH_ALIGN(ndr, 2); NDR_PUSH_NEED_BYTES(ndr, 2); @@ -313,7 +313,7 @@ NTSTATUS ndr_push_int16(struct ndr_push *ndr, int ndr_flags, int16_t v) /* push a uint16_t */ -NTSTATUS ndr_push_uint16(struct ndr_push *ndr, int ndr_flags, uint16_t v) +_PUBLIC_ NTSTATUS ndr_push_uint16(struct ndr_push *ndr, int ndr_flags, uint16_t v) { NDR_PUSH_ALIGN(ndr, 2); NDR_PUSH_NEED_BYTES(ndr, 2); @@ -325,7 +325,7 @@ NTSTATUS ndr_push_uint16(struct ndr_push *ndr, int ndr_flags, uint16_t v) /* push a int32_t */ -NTSTATUS ndr_push_int32(struct ndr_push *ndr, int ndr_flags, int32_t v) +_PUBLIC_ NTSTATUS ndr_push_int32(struct ndr_push *ndr, int ndr_flags, int32_t v) { NDR_PUSH_ALIGN(ndr, 4); NDR_PUSH_NEED_BYTES(ndr, 4); @@ -337,7 +337,7 @@ NTSTATUS ndr_push_int32(struct ndr_push *ndr, int ndr_flags, int32_t v) /* push a uint32_t */ -NTSTATUS ndr_push_uint32(struct ndr_push *ndr, int ndr_flags, uint32_t v) +_PUBLIC_ NTSTATUS ndr_push_uint32(struct ndr_push *ndr, int ndr_flags, uint32_t v) { NDR_PUSH_ALIGN(ndr, 4); NDR_PUSH_NEED_BYTES(ndr, 4); @@ -349,7 +349,7 @@ NTSTATUS ndr_push_uint32(struct ndr_push *ndr, int ndr_flags, uint32_t v) /* push a udlong */ -NTSTATUS ndr_push_udlong(struct ndr_push *ndr, int ndr_flags, uint64_t v) +_PUBLIC_ NTSTATUS ndr_push_udlong(struct ndr_push *ndr, int ndr_flags, uint64_t v) { NDR_PUSH_ALIGN(ndr, 4); NDR_PUSH_NEED_BYTES(ndr, 8); @@ -362,7 +362,7 @@ NTSTATUS ndr_push_udlong(struct ndr_push *ndr, int ndr_flags, uint64_t v) /* push a udlongr */ -NTSTATUS ndr_push_udlongr(struct ndr_push *ndr, int ndr_flags, uint64_t v) +_PUBLIC_ NTSTATUS ndr_push_udlongr(struct ndr_push *ndr, int ndr_flags, uint64_t v) { NDR_PUSH_ALIGN(ndr, 4); NDR_PUSH_NEED_BYTES(ndr, 8); @@ -375,7 +375,7 @@ NTSTATUS ndr_push_udlongr(struct ndr_push *ndr, int ndr_flags, uint64_t v) /* push a dlong */ -NTSTATUS ndr_push_dlong(struct ndr_push *ndr, int ndr_flags, int64_t v) +_PUBLIC_ NTSTATUS ndr_push_dlong(struct ndr_push *ndr, int ndr_flags, int64_t v) { return ndr_push_udlong(ndr, NDR_SCALARS, (uint64_t)v); } @@ -383,7 +383,7 @@ NTSTATUS ndr_push_dlong(struct ndr_push *ndr, int ndr_flags, int64_t v) /* push a hyper */ -NTSTATUS ndr_push_hyper(struct ndr_push *ndr, int ndr_flags, uint64_t v) +_PUBLIC_ NTSTATUS ndr_push_hyper(struct ndr_push *ndr, int ndr_flags, uint64_t v) { NDR_PUSH_ALIGN(ndr, 8); return ndr_push_udlong(ndr, NDR_SCALARS, v); @@ -392,7 +392,7 @@ NTSTATUS ndr_push_hyper(struct ndr_push *ndr, int ndr_flags, uint64_t v) /* push a pointer */ -NTSTATUS ndr_push_pointer(struct ndr_push *ndr, int ndr_flags, void* v) +_PUBLIC_ NTSTATUS ndr_push_pointer(struct ndr_push *ndr, int ndr_flags, void* v) { intptr_t h = (intptr_t)v; NDR_PUSH_ALIGN(ndr, sizeof(h)); @@ -402,13 +402,13 @@ NTSTATUS ndr_push_pointer(struct ndr_push *ndr, int ndr_flags, void* v) return NT_STATUS_OK; } -NTSTATUS ndr_push_align(struct ndr_push *ndr, size_t size) +_PUBLIC_ NTSTATUS ndr_push_align(struct ndr_push *ndr, size_t size) { NDR_PUSH_ALIGN(ndr, size); return NT_STATUS_OK; } -NTSTATUS ndr_pull_align(struct ndr_pull *ndr, size_t size) +_PUBLIC_ NTSTATUS ndr_pull_align(struct ndr_pull *ndr, size_t size) { NDR_PULL_ALIGN(ndr, size); return NT_STATUS_OK; @@ -417,7 +417,7 @@ NTSTATUS ndr_pull_align(struct ndr_pull *ndr, size_t size) /* push some bytes */ -NTSTATUS ndr_push_bytes(struct ndr_push *ndr, const uint8_t *data, uint32_t n) +_PUBLIC_ NTSTATUS ndr_push_bytes(struct ndr_push *ndr, const uint8_t *data, uint32_t n) { NDR_PUSH_NEED_BYTES(ndr, n); memcpy(ndr->data + ndr->offset, data, n); @@ -428,7 +428,7 @@ NTSTATUS ndr_push_bytes(struct ndr_push *ndr, const uint8_t *data, uint32_t n) /* push some zero bytes */ -NTSTATUS ndr_push_zero(struct ndr_push *ndr, uint32_t n) +_PUBLIC_ NTSTATUS ndr_push_zero(struct ndr_push *ndr, uint32_t n) { NDR_PUSH_NEED_BYTES(ndr, n); memset(ndr->data + ndr->offset, 0, n); @@ -439,7 +439,7 @@ NTSTATUS ndr_push_zero(struct ndr_push *ndr, uint32_t n) /* push an array of uint8 */ -NTSTATUS ndr_push_array_uint8(struct ndr_push *ndr, int ndr_flags, const uint8_t *data, uint32_t n) +_PUBLIC_ NTSTATUS ndr_push_array_uint8(struct ndr_push *ndr, int ndr_flags, const uint8_t *data, uint32_t n) { if (!(ndr_flags & NDR_SCALARS)) { return NT_STATUS_OK; @@ -450,7 +450,7 @@ NTSTATUS ndr_push_array_uint8(struct ndr_push *ndr, int ndr_flags, const uint8_t /* save the current position */ -void ndr_push_save(struct ndr_push *ndr, struct ndr_push_save *save) +_PUBLIC_ void ndr_push_save(struct ndr_push *ndr, struct ndr_push_save *save) { save->offset = ndr->offset; } @@ -458,7 +458,7 @@ void ndr_push_save(struct ndr_push *ndr, struct ndr_push_save *save) /* restore the position */ -void ndr_push_restore(struct ndr_push *ndr, struct ndr_push_save *save) +_PUBLIC_ void ndr_push_restore(struct ndr_push *ndr, struct ndr_push_save *save) { ndr->offset = save->offset; } @@ -466,7 +466,7 @@ void ndr_push_restore(struct ndr_push *ndr, struct ndr_push_save *save) /* push a unique non-zero value if a pointer is non-NULL, otherwise 0 */ -NTSTATUS ndr_push_unique_ptr(struct ndr_push *ndr, const void *p) +_PUBLIC_ NTSTATUS ndr_push_unique_ptr(struct ndr_push *ndr, const void *p) { uint32_t ptr = 0; if (p) { @@ -480,7 +480,7 @@ NTSTATUS ndr_push_unique_ptr(struct ndr_push *ndr, const void *p) /* push a 'simple' full non-zero value if a pointer is non-NULL, otherwise 0 */ -NTSTATUS ndr_push_sptr_ptr(struct ndr_push *ndr, const void *p) +_PUBLIC_ NTSTATUS ndr_push_sptr_ptr(struct ndr_push *ndr, const void *p) { uint32_t ptr = 0; if (p) { @@ -493,7 +493,7 @@ NTSTATUS ndr_push_sptr_ptr(struct ndr_push *ndr, const void *p) /* push always a 0, if a pointer is NULL it's a fatal error */ -NTSTATUS ndr_push_ref_ptr(struct ndr_push *ndr, const void *p) +_PUBLIC_ NTSTATUS ndr_push_ref_ptr(struct ndr_push *ndr, const void *p) { if (p == NULL) { return NT_STATUS_INVALID_PARAMETER_MIX; @@ -505,7 +505,7 @@ NTSTATUS ndr_push_ref_ptr(struct ndr_push *ndr, const void *p) /* push a NTTIME */ -NTSTATUS ndr_push_NTTIME(struct ndr_push *ndr, int ndr_flags, NTTIME t) +_PUBLIC_ NTSTATUS ndr_push_NTTIME(struct ndr_push *ndr, int ndr_flags, NTTIME t) { NDR_CHECK(ndr_push_udlong(ndr, ndr_flags, t)); return NT_STATUS_OK; @@ -514,7 +514,7 @@ NTSTATUS ndr_push_NTTIME(struct ndr_push *ndr, int ndr_flags, NTTIME t) /* pull a NTTIME */ -NTSTATUS ndr_pull_NTTIME(struct ndr_pull *ndr, int ndr_flags, NTTIME *t) +_PUBLIC_ NTSTATUS ndr_pull_NTTIME(struct ndr_pull *ndr, int ndr_flags, NTTIME *t) { NDR_CHECK(ndr_pull_udlong(ndr, ndr_flags, t)); return NT_STATUS_OK; @@ -523,7 +523,7 @@ NTSTATUS ndr_pull_NTTIME(struct ndr_pull *ndr, int ndr_flags, NTTIME *t) /* push a NTTIME */ -NTSTATUS ndr_push_NTTIME_1sec(struct ndr_push *ndr, int ndr_flags, NTTIME t) +_PUBLIC_ NTSTATUS ndr_push_NTTIME_1sec(struct ndr_push *ndr, int ndr_flags, NTTIME t) { t /= 10000000; NDR_CHECK(ndr_push_hyper(ndr, ndr_flags, t)); @@ -533,7 +533,7 @@ NTSTATUS ndr_push_NTTIME_1sec(struct ndr_push *ndr, int ndr_flags, NTTIME t) /* pull a NTTIME_1sec */ -NTSTATUS ndr_pull_NTTIME_1sec(struct ndr_pull *ndr, int ndr_flags, NTTIME *t) +_PUBLIC_ NTSTATUS ndr_pull_NTTIME_1sec(struct ndr_pull *ndr, int ndr_flags, NTTIME *t) { NDR_CHECK(ndr_pull_hyper(ndr, ndr_flags, t)); (*t) *= 10000000; @@ -543,7 +543,7 @@ NTSTATUS ndr_pull_NTTIME_1sec(struct ndr_pull *ndr, int ndr_flags, NTTIME *t) /* pull a NTTIME_hyper */ -NTSTATUS ndr_pull_NTTIME_hyper(struct ndr_pull *ndr, int ndr_flags, NTTIME *t) +_PUBLIC_ NTSTATUS ndr_pull_NTTIME_hyper(struct ndr_pull *ndr, int ndr_flags, NTTIME *t) { NDR_CHECK(ndr_pull_hyper(ndr, ndr_flags, t)); return NT_STATUS_OK; @@ -552,7 +552,7 @@ NTSTATUS ndr_pull_NTTIME_hyper(struct ndr_pull *ndr, int ndr_flags, NTTIME *t) /* push a NTTIME_hyper */ -NTSTATUS ndr_push_NTTIME_hyper(struct ndr_push *ndr, int ndr_flags, NTTIME t) +_PUBLIC_ NTSTATUS ndr_push_NTTIME_hyper(struct ndr_push *ndr, int ndr_flags, NTTIME t) { NDR_CHECK(ndr_push_hyper(ndr, ndr_flags, t)); return NT_STATUS_OK; @@ -561,7 +561,7 @@ NTSTATUS ndr_push_NTTIME_hyper(struct ndr_push *ndr, int ndr_flags, NTTIME t) /* push a time_t */ -NTSTATUS ndr_push_time_t(struct ndr_push *ndr, int ndr_flags, time_t t) +_PUBLIC_ NTSTATUS ndr_push_time_t(struct ndr_push *ndr, int ndr_flags, time_t t) { return ndr_push_uint32(ndr, ndr_flags, t); } @@ -569,7 +569,7 @@ NTSTATUS ndr_push_time_t(struct ndr_push *ndr, int ndr_flags, time_t t) /* pull a time_t */ -NTSTATUS ndr_pull_time_t(struct ndr_pull *ndr, int ndr_flags, time_t *t) +_PUBLIC_ NTSTATUS ndr_pull_time_t(struct ndr_pull *ndr, int ndr_flags, time_t *t) { uint32_t tt; NDR_CHECK(ndr_pull_uint32(ndr, ndr_flags, &tt)); @@ -581,7 +581,7 @@ NTSTATUS ndr_pull_time_t(struct ndr_pull *ndr, int ndr_flags, time_t *t) /* pull a ipv4address */ -NTSTATUS ndr_pull_ipv4address(struct ndr_pull *ndr, int ndr_flags, const char **address) +_PUBLIC_ NTSTATUS ndr_pull_ipv4address(struct ndr_pull *ndr, int ndr_flags, const char **address) { struct ipv4_addr in; NDR_CHECK(ndr_pull_uint32(ndr, ndr_flags, &in.addr)); @@ -594,7 +594,7 @@ NTSTATUS ndr_pull_ipv4address(struct ndr_pull *ndr, int ndr_flags, const char ** /* push a ipv4address */ -NTSTATUS ndr_push_ipv4address(struct ndr_push *ndr, int ndr_flags, const char *address) +_PUBLIC_ NTSTATUS ndr_push_ipv4address(struct ndr_push *ndr, int ndr_flags, const char *address) { uint32_t addr; if (!is_ipaddress(address)) { @@ -610,19 +610,19 @@ NTSTATUS ndr_push_ipv4address(struct ndr_push *ndr, int ndr_flags, const char *a /* print a ipv4address */ -void ndr_print_ipv4address(struct ndr_print *ndr, const char *name, +_PUBLIC_ void ndr_print_ipv4address(struct ndr_print *ndr, const char *name, const char *address) { ndr->print(ndr, "%-25s: %s", name, address); } -void ndr_print_struct(struct ndr_print *ndr, const char *name, const char *type) +_PUBLIC_ void ndr_print_struct(struct ndr_print *ndr, const char *name, const char *type) { ndr->print(ndr, "%s: struct %s", name, type); } -void ndr_print_enum(struct ndr_print *ndr, const char *name, const char *type, +_PUBLIC_ void ndr_print_enum(struct ndr_print *ndr, const char *name, const char *type, const char *val, uint_t value) { if (ndr->flags & LIBNDR_PRINT_ARRAY_HEX) { @@ -632,7 +632,7 @@ void ndr_print_enum(struct ndr_print *ndr, const char *name, const char *type, } } -void ndr_print_bitmap_flag(struct ndr_print *ndr, size_t size, const char *flag_name, uint_t flag, uint_t value) +_PUBLIC_ void ndr_print_bitmap_flag(struct ndr_print *ndr, size_t size, const char *flag_name, uint_t flag, uint_t value) { /* this is an attempt to support multi-bit bitmap masks */ value &= flag; @@ -648,62 +648,62 @@ void ndr_print_bitmap_flag(struct ndr_print *ndr, size_t size, const char *flag_ } } -void ndr_print_int8(struct ndr_print *ndr, const char *name, int8_t v) +_PUBLIC_ void ndr_print_int8(struct ndr_print *ndr, const char *name, int8_t v) { ndr->print(ndr, "%-25s: %d", name, v); } -void ndr_print_uint8(struct ndr_print *ndr, const char *name, uint8_t v) +_PUBLIC_ void ndr_print_uint8(struct ndr_print *ndr, const char *name, uint8_t v) { ndr->print(ndr, "%-25s: 0x%02x (%u)", name, v, v); } -void ndr_print_int16(struct ndr_print *ndr, const char *name, int16_t v) +_PUBLIC_ void ndr_print_int16(struct ndr_print *ndr, const char *name, int16_t v) { ndr->print(ndr, "%-25s: %d", name, v); } -void ndr_print_uint16(struct ndr_print *ndr, const char *name, uint16_t v) +_PUBLIC_ void ndr_print_uint16(struct ndr_print *ndr, const char *name, uint16_t v) { ndr->print(ndr, "%-25s: 0x%04x (%u)", name, v, v); } -void ndr_print_int32(struct ndr_print *ndr, const char *name, int32_t v) +_PUBLIC_ void ndr_print_int32(struct ndr_print *ndr, const char *name, int32_t v) { ndr->print(ndr, "%-25s: %d", name, v); } -void ndr_print_uint32(struct ndr_print *ndr, const char *name, uint32_t v) +_PUBLIC_ void ndr_print_uint32(struct ndr_print *ndr, const char *name, uint32_t v) { ndr->print(ndr, "%-25s: 0x%08x (%u)", name, v, v); } -void ndr_print_udlong(struct ndr_print *ndr, const char *name, uint64_t v) +_PUBLIC_ void ndr_print_udlong(struct ndr_print *ndr, const char *name, uint64_t v) { ndr->print(ndr, "%-25s: 0x%016llx (%llu)", name, v, v); } -void ndr_print_udlongr(struct ndr_print *ndr, const char *name, uint64_t v) +_PUBLIC_ void ndr_print_udlongr(struct ndr_print *ndr, const char *name, uint64_t v) { ndr_print_udlong(ndr, name, v); } -void ndr_print_dlong(struct ndr_print *ndr, const char *name, int64_t v) +_PUBLIC_ void ndr_print_dlong(struct ndr_print *ndr, const char *name, int64_t v) { ndr->print(ndr, "%-25s: 0x%016llx (%lld)", name, v, v); } -void ndr_print_hyper(struct ndr_print *ndr, const char *name, uint64_t v) +_PUBLIC_ void ndr_print_hyper(struct ndr_print *ndr, const char *name, uint64_t v) { ndr_print_dlong(ndr, name, v); } -void ndr_print_pointer(struct ndr_print *ndr, const char *name, void *v) +_PUBLIC_ void ndr_print_pointer(struct ndr_print *ndr, const char *name, void *v) { ndr->print(ndr, "%-25s: %p", name, v); } -void ndr_print_ptr(struct ndr_print *ndr, const char *name, const void *p) +_PUBLIC_ void ndr_print_ptr(struct ndr_print *ndr, const char *name, const void *p) { if (p) { ndr->print(ndr, "%-25s: *", name); @@ -712,12 +712,12 @@ void ndr_print_ptr(struct ndr_print *ndr, const char *name, const void *p) } } -void ndr_print_NTTIME(struct ndr_print *ndr, const char *name, NTTIME t) +_PUBLIC_ void ndr_print_NTTIME(struct ndr_print *ndr, const char *name, NTTIME t) { ndr->print(ndr, "%-25s: %s", name, nt_time_string(ndr, t)); } -void ndr_print_NTTIME_1sec(struct ndr_print *ndr, const char *name, NTTIME t) +_PUBLIC_ void ndr_print_NTTIME_1sec(struct ndr_print *ndr, const char *name, NTTIME t) { /* this is a standard NTTIME here * as it's already converted in the pull/push code @@ -725,12 +725,12 @@ void ndr_print_NTTIME_1sec(struct ndr_print *ndr, const char *name, NTTIME t) ndr_print_NTTIME(ndr, name, t); } -void ndr_print_NTTIME_hyper(struct ndr_print *ndr, const char *name, NTTIME t) +_PUBLIC_ void ndr_print_NTTIME_hyper(struct ndr_print *ndr, const char *name, NTTIME t) { ndr_print_NTTIME(ndr, name, t); } -void ndr_print_time_t(struct ndr_print *ndr, const char *name, time_t t) +_PUBLIC_ void ndr_print_time_t(struct ndr_print *ndr, const char *name, time_t t) { if (t == (time_t)-1 || t == 0) { ndr->print(ndr, "%-25s: (time_t)%d", name, (int)t); @@ -739,7 +739,7 @@ void ndr_print_time_t(struct ndr_print *ndr, const char *name, time_t t) } } -void ndr_print_union(struct ndr_print *ndr, const char *name, int level, const char *type) +_PUBLIC_ void ndr_print_union(struct ndr_print *ndr, const char *name, int level, const char *type) { if (ndr->flags & LIBNDR_PRINT_ARRAY_HEX) { ndr->print(ndr, "%-25s: union %s(case 0x%X)", name, type, level); @@ -748,12 +748,12 @@ void ndr_print_union(struct ndr_print *ndr, const char *name, int level, const c } } -void ndr_print_bad_level(struct ndr_print *ndr, const char *name, uint16_t level) +_PUBLIC_ void ndr_print_bad_level(struct ndr_print *ndr, const char *name, uint16_t level) { ndr->print(ndr, "UNKNOWN LEVEL %u", level); } -void ndr_print_array_uint8(struct ndr_print *ndr, const char *name, +_PUBLIC_ void ndr_print_array_uint8(struct ndr_print *ndr, const char *name, const uint8_t *data, uint32_t count) { int i; @@ -781,7 +781,7 @@ void ndr_print_array_uint8(struct ndr_print *ndr, const char *name, ndr->depth--; } -void ndr_print_DATA_BLOB(struct ndr_print *ndr, const char *name, DATA_BLOB r) +_PUBLIC_ void ndr_print_DATA_BLOB(struct ndr_print *ndr, const char *name, DATA_BLOB r) { ndr->print(ndr, "%-25s: DATA_BLOB length=%u", name, r.length); if (r.length) { @@ -793,7 +793,7 @@ void ndr_print_DATA_BLOB(struct ndr_print *ndr, const char *name, DATA_BLOB r) /* push a DATA_BLOB onto the wire. */ -NTSTATUS ndr_push_DATA_BLOB(struct ndr_push *ndr, int ndr_flags, DATA_BLOB blob) +_PUBLIC_ NTSTATUS ndr_push_DATA_BLOB(struct ndr_push *ndr, int ndr_flags, DATA_BLOB blob) { if (ndr->flags & LIBNDR_ALIGN_FLAGS) { if (ndr->flags & LIBNDR_FLAG_ALIGN2) { @@ -815,7 +815,7 @@ NTSTATUS ndr_push_DATA_BLOB(struct ndr_push *ndr, int ndr_flags, DATA_BLOB blob) /* pull a DATA_BLOB from the wire. */ -NTSTATUS ndr_pull_DATA_BLOB(struct ndr_pull *ndr, int ndr_flags, DATA_BLOB *blob) +_PUBLIC_ NTSTATUS ndr_pull_DATA_BLOB(struct ndr_pull *ndr, int ndr_flags, DATA_BLOB *blob) { uint32_t length; @@ -841,7 +841,7 @@ NTSTATUS ndr_pull_DATA_BLOB(struct ndr_pull *ndr, int ndr_flags, DATA_BLOB *blob return NT_STATUS_OK; } -uint32_t ndr_size_DATA_BLOB(int ret, const DATA_BLOB *data, int flags) +_PUBLIC_ uint32_t ndr_size_DATA_BLOB(int ret, const DATA_BLOB *data, int flags) { return ret + data->length; } -- cgit From 65238dc9402a2e79087091ed587d5d6e703c63b7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 13 Mar 2006 06:58:51 +0000 Subject: r14310: length needs to be initialised (This used to be commit 20d7f2ae35761533613f9d6dcf941a5ef3c7e07b) --- source4/librpc/ndr/ndr_basic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 000a0c3498..780931efb1 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -817,7 +817,7 @@ _PUBLIC_ NTSTATUS ndr_push_DATA_BLOB(struct ndr_push *ndr, int ndr_flags, DATA_B */ _PUBLIC_ NTSTATUS ndr_pull_DATA_BLOB(struct ndr_pull *ndr, int ndr_flags, DATA_BLOB *blob) { - uint32_t length; + uint32_t length = 0; if (ndr->flags & LIBNDR_ALIGN_FLAGS) { if (ndr->flags & LIBNDR_FLAG_ALIGN2) { -- cgit From 35349a58df5b69446607fbd742a05f57f3515319 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 18 Mar 2006 15:42:57 +0000 Subject: r14542: Remove librpc, libndr and libnbt from includes.h (This used to be commit 51b4270513752d2eafbe77f9de598de16ef84a1f) --- source4/librpc/ndr/ndr_basic.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 780931efb1..4b0444f00b 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -22,6 +22,7 @@ #include "includes.h" #include "system/network.h" +#include "librpc/ndr/libndr.h" #define NDR_SVAL(ndr, ofs) (NDR_BE(ndr)?RSVAL(ndr->data,ofs):SVAL(ndr->data,ofs)) #define NDR_IVAL(ndr, ofs) (NDR_BE(ndr)?RIVAL(ndr->data,ofs):IVAL(ndr->data,ofs)) -- cgit From 37aa2c5e8ff628d8ad51497a165da8a58cb2d1f5 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 3 May 2006 09:10:45 +0000 Subject: r15407: Get rid of some more uint_t (This used to be commit 897329c2534dc8e24670b91bc448939141f27417) --- source4/librpc/ndr/ndr_basic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 4b0444f00b..197fd44895 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -624,7 +624,7 @@ _PUBLIC_ void ndr_print_struct(struct ndr_print *ndr, const char *name, const ch } _PUBLIC_ void ndr_print_enum(struct ndr_print *ndr, const char *name, const char *type, - const char *val, uint_t value) + const char *val, uint32_t value) { if (ndr->flags & LIBNDR_PRINT_ARRAY_HEX) { ndr->print(ndr, "%-25s: %s (0x%X)", name, val?val:"UNKNOWN_ENUM_VALUE", value); @@ -633,7 +633,7 @@ _PUBLIC_ void ndr_print_enum(struct ndr_print *ndr, const char *name, const char } } -_PUBLIC_ void ndr_print_bitmap_flag(struct ndr_print *ndr, size_t size, const char *flag_name, uint_t flag, uint_t value) +_PUBLIC_ void ndr_print_bitmap_flag(struct ndr_print *ndr, size_t size, const char *flag_name, uint32_t flag, uint32_t value) { /* this is an attempt to support multi-bit bitmap masks */ value &= flag; -- cgit From 9727b061f330ba8f500a29bf4b94992e2bceffbc Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 21 May 2006 12:58:39 +0000 Subject: r15776: Don't generate ref pointers in Samba4-generated code. There is no point in having pointers for outgoing data when you can already modify the top-level element. This can be overridden (temporarily) by specifying the new "keepref" attribute. Once we've removed keepref from all IDL files, I'll remove this attribute as well. (This used to be commit bdc6dd37503ced8322a671d225122ccffbb8bfec) --- source4/librpc/ndr/ndr_basic.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 197fd44895..f4ba786865 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -494,11 +494,8 @@ _PUBLIC_ NTSTATUS ndr_push_sptr_ptr(struct ndr_push *ndr, const void *p) /* push always a 0, if a pointer is NULL it's a fatal error */ -_PUBLIC_ NTSTATUS ndr_push_ref_ptr(struct ndr_push *ndr, const void *p) +_PUBLIC_ NTSTATUS ndr_push_ref_ptr(struct ndr_push *ndr) { - if (p == NULL) { - return NT_STATUS_INVALID_PARAMETER_MIX; - } return ndr_push_uint32(ndr, NDR_SCALARS, 0xAEF1AEF1); } -- cgit From 30ee8beb9316a99e8a49993306252591106cb349 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 9 Sep 2006 10:05:58 +0000 Subject: r18301: I discovered how to load the warnings from a build farm build into emacs compile mode (hint, paste to a file, and compile as "cat filename"). This allowed me to fix nearly all the warnings for a IA_64 SuSE build very quickly. (This used to be commit eba6c84efff735bb0ca941ac4b755ce2b0591667) --- source4/librpc/ndr/ndr_basic.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index f4ba786865..ed79f354fa 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -678,7 +678,7 @@ _PUBLIC_ void ndr_print_uint32(struct ndr_print *ndr, const char *name, uint32_t _PUBLIC_ void ndr_print_udlong(struct ndr_print *ndr, const char *name, uint64_t v) { - ndr->print(ndr, "%-25s: 0x%016llx (%llu)", name, v, v); + ndr->print(ndr, "%-25s: 0x%016llx (%llu)", name, (unsigned long long)v, (unsigned long long)v); } _PUBLIC_ void ndr_print_udlongr(struct ndr_print *ndr, const char *name, uint64_t v) @@ -688,7 +688,7 @@ _PUBLIC_ void ndr_print_udlongr(struct ndr_print *ndr, const char *name, uint64_ _PUBLIC_ void ndr_print_dlong(struct ndr_print *ndr, const char *name, int64_t v) { - ndr->print(ndr, "%-25s: 0x%016llx (%lld)", name, v, v); + ndr->print(ndr, "%-25s: 0x%016llx (%lld)", name, (unsigned long long)v, (long long)v); } _PUBLIC_ void ndr_print_hyper(struct ndr_print *ndr, const char *name, uint64_t v) @@ -781,7 +781,7 @@ _PUBLIC_ void ndr_print_array_uint8(struct ndr_print *ndr, const char *name, _PUBLIC_ void ndr_print_DATA_BLOB(struct ndr_print *ndr, const char *name, DATA_BLOB r) { - ndr->print(ndr, "%-25s: DATA_BLOB length=%u", name, r.length); + ndr->print(ndr, "%-25s: DATA_BLOB length=%u", name, (unsigned)r.length); if (r.length) { dump_data(10, r.data, r.length); } -- cgit From 128fe5324b803e0989273c7033ec0b5c8bd3dbae Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 23 Nov 2006 13:48:01 +0000 Subject: r19856: Use sptr as basis for full ptr implementation. Will add checks for duplicates later. (This used to be commit 006ab1d4a449c81680add57e0116a86b8317fbfb) --- source4/librpc/ndr/ndr_basic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index ed79f354fa..b8f2a8115f 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -481,7 +481,7 @@ _PUBLIC_ NTSTATUS ndr_push_unique_ptr(struct ndr_push *ndr, const void *p) /* push a 'simple' full non-zero value if a pointer is non-NULL, otherwise 0 */ -_PUBLIC_ NTSTATUS ndr_push_sptr_ptr(struct ndr_push *ndr, const void *p) +_PUBLIC_ NTSTATUS ndr_push_full_ptr(struct ndr_push *ndr, const void *p) { uint32_t ptr = 0; if (p) { -- cgit From 8d870db811ef4f120d7df3b3f50243b47d94da2f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 23 Nov 2006 16:02:20 +0000 Subject: r19859: Reuse referrent ids when pushing full pointers (still need to avoid pushing the referred object twice) and add test for full pointers. (This used to be commit 1638c8d234dbc85298000685e49570f23dfd0bf8) --- source4/librpc/ndr/ndr_basic.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index b8f2a8115f..a9cfb558f7 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -485,8 +485,13 @@ _PUBLIC_ NTSTATUS ndr_push_full_ptr(struct ndr_push *ndr, const void *p) { uint32_t ptr = 0; if (p) { - ndr->ptr_count++; - ptr = ndr->ptr_count; + /* Check if the pointer already exists and has an id */ + ptr = ndr_token_peek(&ndr->full_ptr_list, p); + if (ptr == 0) { + ndr->ptr_count++; + ptr = ndr->ptr_count; + ndr_token_store(ndr, &ndr->full_ptr_list, p, ptr); + } } return ndr_push_uint32(ndr, NDR_SCALARS, ptr); } -- cgit From bb75710d40e11f127270e2d39c957db64da63a60 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 30 Dec 2006 10:42:01 +0000 Subject: r20417: - fix pushing of drsuapi_DsAttributeValueDataBlob - make drsuapi_DsReplicaAttribute public so that the ndr_print_* function can be used from the outside metze (This used to be commit f12776b9a9de55d5c67335d5e59c0d83a74ac939) --- source4/librpc/ndr/ndr_basic.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index a9cfb558f7..04589d3e96 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -846,5 +846,6 @@ _PUBLIC_ NTSTATUS ndr_pull_DATA_BLOB(struct ndr_pull *ndr, int ndr_flags, DATA_B _PUBLIC_ uint32_t ndr_size_DATA_BLOB(int ret, const DATA_BLOB *data, int flags) { + if (!data) return ret; return ret + data->length; } -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/librpc/ndr/ndr_basic.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 04589d3e96..c0a021e677 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -7,7 +7,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -16,8 +16,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From b09047b78e981af8ade6a72d426bfcb0e742995b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 13 Oct 2007 20:24:37 +0200 Subject: r25624: Remove ipv4_addr hack. Only causes 4 extra includes of system/network.h because we stripped down includes. (This used to be commit 262c1c23a61f1f4fae13e0a61179fe98b682cecf) --- source4/librpc/ndr/ndr_basic.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index c0a021e677..a26b67af22 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -585,10 +585,10 @@ _PUBLIC_ NTSTATUS ndr_pull_time_t(struct ndr_pull *ndr, int ndr_flags, time_t *t */ _PUBLIC_ NTSTATUS ndr_pull_ipv4address(struct ndr_pull *ndr, int ndr_flags, const char **address) { - struct ipv4_addr in; - NDR_CHECK(ndr_pull_uint32(ndr, ndr_flags, &in.addr)); - in.addr = htonl(in.addr); - *address = talloc_strdup(ndr->current_mem_ctx, sys_inet_ntoa(in)); + struct in_addr in; + NDR_CHECK(ndr_pull_uint32(ndr, ndr_flags, &in.s_addr)); + in.s_addr = htonl(in.s_addr); + *address = talloc_strdup(ndr->current_mem_ctx, inet_ntoa(in)); NT_STATUS_HAVE_NO_MEMORY(*address); return NT_STATUS_OK; } -- cgit From fb4032a470e3b058cd91da86006f69a5cd2bd8ff Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 2 Nov 2007 10:32:47 +0100 Subject: r25794: use NDR_CHECK() metze (This used to be commit 614e812bb01ebaa39db10c25cd011bef7f1279b2) --- source4/librpc/ndr/ndr_basic.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index a26b67af22..b406791a27 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -130,12 +130,11 @@ _PUBLIC_ NTSTATUS ndr_pull_uint32(struct ndr_pull *ndr, int ndr_flags, uint32_t */ _PUBLIC_ NTSTATUS ndr_pull_generic_ptr(struct ndr_pull *ndr, uint32_t *v) { - NTSTATUS status; - status = ndr_pull_uint32(ndr, NDR_SCALARS, v); - if (NT_STATUS_IS_OK(status) && *v != 0) { + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, v)); + if (*v != 0) { ndr->ptr_count++; } - return status; + return NT_STATUS_OK; } /* -- cgit From afa5f256e9023332a50a410b53e3c1c94af0e85a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 9 Nov 2007 19:23:40 +0100 Subject: r25916: ndr: change NTSTAUS into enum ndr_err_code (basic stuff) librpc/ndr/ metze (This used to be commit 7e157bbcfd416c3d5c32c1e9fdc746bbee5967bb) --- source4/librpc/ndr/ndr_basic.c | 182 ++++++++++++++++++++--------------------- 1 file changed, 91 insertions(+), 91 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index b406791a27..0ef78a2a54 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -58,126 +58,126 @@ _PUBLIC_ void ndr_check_padding(struct ndr_pull *ndr, size_t n) /* parse a int8_t */ -_PUBLIC_ NTSTATUS ndr_pull_int8(struct ndr_pull *ndr, int ndr_flags, int8_t *v) +_PUBLIC_ enum ndr_err_code ndr_pull_int8(struct ndr_pull *ndr, int ndr_flags, int8_t *v) { NDR_PULL_NEED_BYTES(ndr, 1); *v = (int8_t)CVAL(ndr->data, ndr->offset); ndr->offset += 1; - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /* parse a uint8_t */ -_PUBLIC_ NTSTATUS ndr_pull_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *v) +_PUBLIC_ enum ndr_err_code ndr_pull_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *v) { NDR_PULL_NEED_BYTES(ndr, 1); *v = CVAL(ndr->data, ndr->offset); ndr->offset += 1; - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /* parse a int16_t */ -_PUBLIC_ NTSTATUS ndr_pull_int16(struct ndr_pull *ndr, int ndr_flags, int16_t *v) +_PUBLIC_ enum ndr_err_code ndr_pull_int16(struct ndr_pull *ndr, int ndr_flags, int16_t *v) { NDR_PULL_ALIGN(ndr, 2); NDR_PULL_NEED_BYTES(ndr, 2); *v = (uint16_t)NDR_SVAL(ndr, ndr->offset); ndr->offset += 2; - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /* parse a uint16_t */ -_PUBLIC_ NTSTATUS ndr_pull_uint16(struct ndr_pull *ndr, int ndr_flags, uint16_t *v) +_PUBLIC_ enum ndr_err_code ndr_pull_uint16(struct ndr_pull *ndr, int ndr_flags, uint16_t *v) { NDR_PULL_ALIGN(ndr, 2); NDR_PULL_NEED_BYTES(ndr, 2); *v = NDR_SVAL(ndr, ndr->offset); ndr->offset += 2; - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /* parse a int32_t */ -_PUBLIC_ NTSTATUS ndr_pull_int32(struct ndr_pull *ndr, int ndr_flags, int32_t *v) +_PUBLIC_ enum ndr_err_code ndr_pull_int32(struct ndr_pull *ndr, int ndr_flags, int32_t *v) { NDR_PULL_ALIGN(ndr, 4); NDR_PULL_NEED_BYTES(ndr, 4); *v = NDR_IVALS(ndr, ndr->offset); ndr->offset += 4; - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /* parse a uint32_t */ -_PUBLIC_ NTSTATUS ndr_pull_uint32(struct ndr_pull *ndr, int ndr_flags, uint32_t *v) +_PUBLIC_ enum ndr_err_code ndr_pull_uint32(struct ndr_pull *ndr, int ndr_flags, uint32_t *v) { NDR_PULL_ALIGN(ndr, 4); NDR_PULL_NEED_BYTES(ndr, 4); *v = NDR_IVAL(ndr, ndr->offset); ndr->offset += 4; - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /* parse a pointer referent identifier */ -_PUBLIC_ NTSTATUS ndr_pull_generic_ptr(struct ndr_pull *ndr, uint32_t *v) +_PUBLIC_ enum ndr_err_code ndr_pull_generic_ptr(struct ndr_pull *ndr, uint32_t *v) { NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, v)); if (*v != 0) { ndr->ptr_count++; } - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /* parse a ref pointer referent identifier */ -_PUBLIC_ NTSTATUS ndr_pull_ref_ptr(struct ndr_pull *ndr, uint32_t *v) +_PUBLIC_ enum ndr_err_code ndr_pull_ref_ptr(struct ndr_pull *ndr, uint32_t *v) { NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, v)); /* ref pointers always point to data */ *v = 1; - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /* parse a udlong */ -_PUBLIC_ NTSTATUS ndr_pull_udlong(struct ndr_pull *ndr, int ndr_flags, uint64_t *v) +_PUBLIC_ enum ndr_err_code ndr_pull_udlong(struct ndr_pull *ndr, int ndr_flags, uint64_t *v) { NDR_PULL_ALIGN(ndr, 4); NDR_PULL_NEED_BYTES(ndr, 8); *v = NDR_IVAL(ndr, ndr->offset); *v |= (uint64_t)(NDR_IVAL(ndr, ndr->offset+4)) << 32; ndr->offset += 8; - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /* parse a udlongr */ -_PUBLIC_ NTSTATUS ndr_pull_udlongr(struct ndr_pull *ndr, int ndr_flags, uint64_t *v) +_PUBLIC_ enum ndr_err_code ndr_pull_udlongr(struct ndr_pull *ndr, int ndr_flags, uint64_t *v) { NDR_PULL_ALIGN(ndr, 4); NDR_PULL_NEED_BYTES(ndr, 8); *v = ((uint64_t)NDR_IVAL(ndr, ndr->offset)) << 32; *v |= NDR_IVAL(ndr, ndr->offset+4); ndr->offset += 8; - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /* parse a dlong */ -_PUBLIC_ NTSTATUS ndr_pull_dlong(struct ndr_pull *ndr, int ndr_flags, int64_t *v) +_PUBLIC_ enum ndr_err_code ndr_pull_dlong(struct ndr_pull *ndr, int ndr_flags, int64_t *v) { return ndr_pull_udlong(ndr, ndr_flags, (uint64_t *)v); } @@ -185,7 +185,7 @@ _PUBLIC_ NTSTATUS ndr_pull_dlong(struct ndr_pull *ndr, int ndr_flags, int64_t *v /* parse a hyper */ -_PUBLIC_ NTSTATUS ndr_pull_hyper(struct ndr_pull *ndr, int ndr_flags, uint64_t *v) +_PUBLIC_ enum ndr_err_code ndr_pull_hyper(struct ndr_pull *ndr, int ndr_flags, uint64_t *v) { NDR_PULL_ALIGN(ndr, 8); return ndr_pull_udlong(ndr, ndr_flags, v); @@ -194,7 +194,7 @@ _PUBLIC_ NTSTATUS ndr_pull_hyper(struct ndr_pull *ndr, int ndr_flags, uint64_t * /* parse a pointer */ -_PUBLIC_ NTSTATUS ndr_pull_pointer(struct ndr_pull *ndr, int ndr_flags, void* *v) +_PUBLIC_ enum ndr_err_code ndr_pull_pointer(struct ndr_pull *ndr, int ndr_flags, void* *v) { intptr_t h; NDR_PULL_ALIGN(ndr, sizeof(h)); @@ -202,24 +202,24 @@ _PUBLIC_ NTSTATUS ndr_pull_pointer(struct ndr_pull *ndr, int ndr_flags, void* *v memcpy(&h, ndr->data+ndr->offset, sizeof(h)); ndr->offset += sizeof(h); *v = (void *)h; - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /* pull a NTSTATUS */ -_PUBLIC_ NTSTATUS ndr_pull_NTSTATUS(struct ndr_pull *ndr, int ndr_flags, NTSTATUS *status) +_PUBLIC_ enum ndr_err_code ndr_pull_NTSTATUS(struct ndr_pull *ndr, int ndr_flags, NTSTATUS *status) { uint32_t v; NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v)); *status = NT_STATUS(v); - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /* push a NTSTATUS */ -_PUBLIC_ NTSTATUS ndr_push_NTSTATUS(struct ndr_push *ndr, int ndr_flags, NTSTATUS status) +_PUBLIC_ enum ndr_err_code ndr_push_NTSTATUS(struct ndr_push *ndr, int ndr_flags, NTSTATUS status) { return ndr_push_uint32(ndr, ndr_flags, NT_STATUS_V(status)); } @@ -232,18 +232,18 @@ _PUBLIC_ void ndr_print_NTSTATUS(struct ndr_print *ndr, const char *name, NTSTAT /* pull a WERROR */ -_PUBLIC_ NTSTATUS ndr_pull_WERROR(struct ndr_pull *ndr, int ndr_flags, WERROR *status) +_PUBLIC_ enum ndr_err_code ndr_pull_WERROR(struct ndr_pull *ndr, int ndr_flags, WERROR *status) { uint32_t v; NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v)); *status = W_ERROR(v); - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /* push a WERROR */ -_PUBLIC_ NTSTATUS ndr_push_WERROR(struct ndr_push *ndr, int ndr_flags, WERROR status) +_PUBLIC_ enum ndr_err_code ndr_push_WERROR(struct ndr_push *ndr, int ndr_flags, WERROR status) { return ndr_push_uint32(ndr, NDR_SCALARS, W_ERROR_V(status)); } @@ -256,21 +256,21 @@ _PUBLIC_ void ndr_print_WERROR(struct ndr_print *ndr, const char *name, WERROR r /* parse a set of bytes */ -_PUBLIC_ NTSTATUS ndr_pull_bytes(struct ndr_pull *ndr, uint8_t *data, uint32_t n) +_PUBLIC_ enum ndr_err_code ndr_pull_bytes(struct ndr_pull *ndr, uint8_t *data, uint32_t n) { NDR_PULL_NEED_BYTES(ndr, n); memcpy(data, ndr->data + ndr->offset, n); ndr->offset += n; - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /* pull an array of uint8 */ -_PUBLIC_ NTSTATUS ndr_pull_array_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *data, uint32_t n) +_PUBLIC_ enum ndr_err_code ndr_pull_array_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *data, uint32_t n) { if (!(ndr_flags & NDR_SCALARS)) { - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } return ndr_pull_bytes(ndr, data, n); } @@ -278,103 +278,103 @@ _PUBLIC_ NTSTATUS ndr_pull_array_uint8(struct ndr_pull *ndr, int ndr_flags, uint /* push a int8_t */ -_PUBLIC_ NTSTATUS ndr_push_int8(struct ndr_push *ndr, int ndr_flags, int8_t v) +_PUBLIC_ enum ndr_err_code ndr_push_int8(struct ndr_push *ndr, int ndr_flags, int8_t v) { NDR_PUSH_NEED_BYTES(ndr, 1); SCVAL(ndr->data, ndr->offset, (uint8_t)v); ndr->offset += 1; - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /* push a uint8_t */ -_PUBLIC_ NTSTATUS ndr_push_uint8(struct ndr_push *ndr, int ndr_flags, uint8_t v) +_PUBLIC_ enum ndr_err_code ndr_push_uint8(struct ndr_push *ndr, int ndr_flags, uint8_t v) { NDR_PUSH_NEED_BYTES(ndr, 1); SCVAL(ndr->data, ndr->offset, v); ndr->offset += 1; - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /* push a int16_t */ -_PUBLIC_ NTSTATUS ndr_push_int16(struct ndr_push *ndr, int ndr_flags, int16_t v) +_PUBLIC_ enum ndr_err_code ndr_push_int16(struct ndr_push *ndr, int ndr_flags, int16_t v) { NDR_PUSH_ALIGN(ndr, 2); NDR_PUSH_NEED_BYTES(ndr, 2); NDR_SSVAL(ndr, ndr->offset, (uint16_t)v); ndr->offset += 2; - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /* push a uint16_t */ -_PUBLIC_ NTSTATUS ndr_push_uint16(struct ndr_push *ndr, int ndr_flags, uint16_t v) +_PUBLIC_ enum ndr_err_code ndr_push_uint16(struct ndr_push *ndr, int ndr_flags, uint16_t v) { NDR_PUSH_ALIGN(ndr, 2); NDR_PUSH_NEED_BYTES(ndr, 2); NDR_SSVAL(ndr, ndr->offset, v); ndr->offset += 2; - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /* push a int32_t */ -_PUBLIC_ NTSTATUS ndr_push_int32(struct ndr_push *ndr, int ndr_flags, int32_t v) +_PUBLIC_ enum ndr_err_code ndr_push_int32(struct ndr_push *ndr, int ndr_flags, int32_t v) { NDR_PUSH_ALIGN(ndr, 4); NDR_PUSH_NEED_BYTES(ndr, 4); NDR_SIVALS(ndr, ndr->offset, v); ndr->offset += 4; - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /* push a uint32_t */ -_PUBLIC_ NTSTATUS ndr_push_uint32(struct ndr_push *ndr, int ndr_flags, uint32_t v) +_PUBLIC_ enum ndr_err_code ndr_push_uint32(struct ndr_push *ndr, int ndr_flags, uint32_t v) { NDR_PUSH_ALIGN(ndr, 4); NDR_PUSH_NEED_BYTES(ndr, 4); NDR_SIVAL(ndr, ndr->offset, v); ndr->offset += 4; - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /* push a udlong */ -_PUBLIC_ NTSTATUS ndr_push_udlong(struct ndr_push *ndr, int ndr_flags, uint64_t v) +_PUBLIC_ enum ndr_err_code ndr_push_udlong(struct ndr_push *ndr, int ndr_flags, uint64_t v) { NDR_PUSH_ALIGN(ndr, 4); NDR_PUSH_NEED_BYTES(ndr, 8); NDR_SIVAL(ndr, ndr->offset, (v & 0xFFFFFFFF)); NDR_SIVAL(ndr, ndr->offset+4, (v>>32)); ndr->offset += 8; - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /* push a udlongr */ -_PUBLIC_ NTSTATUS ndr_push_udlongr(struct ndr_push *ndr, int ndr_flags, uint64_t v) +_PUBLIC_ enum ndr_err_code ndr_push_udlongr(struct ndr_push *ndr, int ndr_flags, uint64_t v) { NDR_PUSH_ALIGN(ndr, 4); NDR_PUSH_NEED_BYTES(ndr, 8); NDR_SIVAL(ndr, ndr->offset, (v>>32)); NDR_SIVAL(ndr, ndr->offset+4, (v & 0xFFFFFFFF)); ndr->offset += 8; - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /* push a dlong */ -_PUBLIC_ NTSTATUS ndr_push_dlong(struct ndr_push *ndr, int ndr_flags, int64_t v) +_PUBLIC_ enum ndr_err_code ndr_push_dlong(struct ndr_push *ndr, int ndr_flags, int64_t v) { return ndr_push_udlong(ndr, NDR_SCALARS, (uint64_t)v); } @@ -382,7 +382,7 @@ _PUBLIC_ NTSTATUS ndr_push_dlong(struct ndr_push *ndr, int ndr_flags, int64_t v) /* push a hyper */ -_PUBLIC_ NTSTATUS ndr_push_hyper(struct ndr_push *ndr, int ndr_flags, uint64_t v) +_PUBLIC_ enum ndr_err_code ndr_push_hyper(struct ndr_push *ndr, int ndr_flags, uint64_t v) { NDR_PUSH_ALIGN(ndr, 8); return ndr_push_udlong(ndr, NDR_SCALARS, v); @@ -391,57 +391,57 @@ _PUBLIC_ NTSTATUS ndr_push_hyper(struct ndr_push *ndr, int ndr_flags, uint64_t v /* push a pointer */ -_PUBLIC_ NTSTATUS ndr_push_pointer(struct ndr_push *ndr, int ndr_flags, void* v) +_PUBLIC_ enum ndr_err_code ndr_push_pointer(struct ndr_push *ndr, int ndr_flags, void* v) { intptr_t h = (intptr_t)v; NDR_PUSH_ALIGN(ndr, sizeof(h)); NDR_PUSH_NEED_BYTES(ndr, sizeof(h)); memcpy(ndr->data+ndr->offset, &h, sizeof(h)); ndr->offset += sizeof(h); - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } -_PUBLIC_ NTSTATUS ndr_push_align(struct ndr_push *ndr, size_t size) +_PUBLIC_ enum ndr_err_code ndr_push_align(struct ndr_push *ndr, size_t size) { NDR_PUSH_ALIGN(ndr, size); - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } -_PUBLIC_ NTSTATUS ndr_pull_align(struct ndr_pull *ndr, size_t size) +_PUBLIC_ enum ndr_err_code ndr_pull_align(struct ndr_pull *ndr, size_t size) { NDR_PULL_ALIGN(ndr, size); - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /* push some bytes */ -_PUBLIC_ NTSTATUS ndr_push_bytes(struct ndr_push *ndr, const uint8_t *data, uint32_t n) +_PUBLIC_ enum ndr_err_code ndr_push_bytes(struct ndr_push *ndr, const uint8_t *data, uint32_t n) { NDR_PUSH_NEED_BYTES(ndr, n); memcpy(ndr->data + ndr->offset, data, n); ndr->offset += n; - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /* push some zero bytes */ -_PUBLIC_ NTSTATUS ndr_push_zero(struct ndr_push *ndr, uint32_t n) +_PUBLIC_ enum ndr_err_code ndr_push_zero(struct ndr_push *ndr, uint32_t n) { NDR_PUSH_NEED_BYTES(ndr, n); memset(ndr->data + ndr->offset, 0, n); ndr->offset += n; - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /* push an array of uint8 */ -_PUBLIC_ NTSTATUS ndr_push_array_uint8(struct ndr_push *ndr, int ndr_flags, const uint8_t *data, uint32_t n) +_PUBLIC_ enum ndr_err_code ndr_push_array_uint8(struct ndr_push *ndr, int ndr_flags, const uint8_t *data, uint32_t n) { if (!(ndr_flags & NDR_SCALARS)) { - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } return ndr_push_bytes(ndr, data, n); } @@ -465,7 +465,7 @@ _PUBLIC_ void ndr_push_restore(struct ndr_push *ndr, struct ndr_push_save *save) /* push a unique non-zero value if a pointer is non-NULL, otherwise 0 */ -_PUBLIC_ NTSTATUS ndr_push_unique_ptr(struct ndr_push *ndr, const void *p) +_PUBLIC_ enum ndr_err_code ndr_push_unique_ptr(struct ndr_push *ndr, const void *p) { uint32_t ptr = 0; if (p) { @@ -479,7 +479,7 @@ _PUBLIC_ NTSTATUS ndr_push_unique_ptr(struct ndr_push *ndr, const void *p) /* push a 'simple' full non-zero value if a pointer is non-NULL, otherwise 0 */ -_PUBLIC_ NTSTATUS ndr_push_full_ptr(struct ndr_push *ndr, const void *p) +_PUBLIC_ enum ndr_err_code ndr_push_full_ptr(struct ndr_push *ndr, const void *p) { uint32_t ptr = 0; if (p) { @@ -497,7 +497,7 @@ _PUBLIC_ NTSTATUS ndr_push_full_ptr(struct ndr_push *ndr, const void *p) /* push always a 0, if a pointer is NULL it's a fatal error */ -_PUBLIC_ NTSTATUS ndr_push_ref_ptr(struct ndr_push *ndr) +_PUBLIC_ enum ndr_err_code ndr_push_ref_ptr(struct ndr_push *ndr) { return ndr_push_uint32(ndr, NDR_SCALARS, 0xAEF1AEF1); } @@ -506,63 +506,63 @@ _PUBLIC_ NTSTATUS ndr_push_ref_ptr(struct ndr_push *ndr) /* push a NTTIME */ -_PUBLIC_ NTSTATUS ndr_push_NTTIME(struct ndr_push *ndr, int ndr_flags, NTTIME t) +_PUBLIC_ enum ndr_err_code ndr_push_NTTIME(struct ndr_push *ndr, int ndr_flags, NTTIME t) { NDR_CHECK(ndr_push_udlong(ndr, ndr_flags, t)); - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /* pull a NTTIME */ -_PUBLIC_ NTSTATUS ndr_pull_NTTIME(struct ndr_pull *ndr, int ndr_flags, NTTIME *t) +_PUBLIC_ enum ndr_err_code ndr_pull_NTTIME(struct ndr_pull *ndr, int ndr_flags, NTTIME *t) { NDR_CHECK(ndr_pull_udlong(ndr, ndr_flags, t)); - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /* push a NTTIME */ -_PUBLIC_ NTSTATUS ndr_push_NTTIME_1sec(struct ndr_push *ndr, int ndr_flags, NTTIME t) +_PUBLIC_ enum ndr_err_code ndr_push_NTTIME_1sec(struct ndr_push *ndr, int ndr_flags, NTTIME t) { t /= 10000000; NDR_CHECK(ndr_push_hyper(ndr, ndr_flags, t)); - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /* pull a NTTIME_1sec */ -_PUBLIC_ NTSTATUS ndr_pull_NTTIME_1sec(struct ndr_pull *ndr, int ndr_flags, NTTIME *t) +_PUBLIC_ enum ndr_err_code ndr_pull_NTTIME_1sec(struct ndr_pull *ndr, int ndr_flags, NTTIME *t) { NDR_CHECK(ndr_pull_hyper(ndr, ndr_flags, t)); (*t) *= 10000000; - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /* pull a NTTIME_hyper */ -_PUBLIC_ NTSTATUS ndr_pull_NTTIME_hyper(struct ndr_pull *ndr, int ndr_flags, NTTIME *t) +_PUBLIC_ enum ndr_err_code ndr_pull_NTTIME_hyper(struct ndr_pull *ndr, int ndr_flags, NTTIME *t) { NDR_CHECK(ndr_pull_hyper(ndr, ndr_flags, t)); - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /* push a NTTIME_hyper */ -_PUBLIC_ NTSTATUS ndr_push_NTTIME_hyper(struct ndr_push *ndr, int ndr_flags, NTTIME t) +_PUBLIC_ enum ndr_err_code ndr_push_NTTIME_hyper(struct ndr_push *ndr, int ndr_flags, NTTIME t) { NDR_CHECK(ndr_push_hyper(ndr, ndr_flags, t)); - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /* push a time_t */ -_PUBLIC_ NTSTATUS ndr_push_time_t(struct ndr_push *ndr, int ndr_flags, time_t t) +_PUBLIC_ enum ndr_err_code ndr_push_time_t(struct ndr_push *ndr, int ndr_flags, time_t t) { return ndr_push_uint32(ndr, ndr_flags, t); } @@ -570,32 +570,32 @@ _PUBLIC_ NTSTATUS ndr_push_time_t(struct ndr_push *ndr, int ndr_flags, time_t t) /* pull a time_t */ -_PUBLIC_ NTSTATUS ndr_pull_time_t(struct ndr_pull *ndr, int ndr_flags, time_t *t) +_PUBLIC_ enum ndr_err_code ndr_pull_time_t(struct ndr_pull *ndr, int ndr_flags, time_t *t) { uint32_t tt; NDR_CHECK(ndr_pull_uint32(ndr, ndr_flags, &tt)); *t = tt; - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /* pull a ipv4address */ -_PUBLIC_ NTSTATUS ndr_pull_ipv4address(struct ndr_pull *ndr, int ndr_flags, const char **address) +_PUBLIC_ enum ndr_err_code ndr_pull_ipv4address(struct ndr_pull *ndr, int ndr_flags, const char **address) { struct in_addr in; NDR_CHECK(ndr_pull_uint32(ndr, ndr_flags, &in.s_addr)); in.s_addr = htonl(in.s_addr); *address = talloc_strdup(ndr->current_mem_ctx, inet_ntoa(in)); - NT_STATUS_HAVE_NO_MEMORY(*address); - return NT_STATUS_OK; + NDR_ERR_HAVE_NO_MEMORY(*address); + return NDR_ERR_SUCCESS; } /* push a ipv4address */ -_PUBLIC_ NTSTATUS ndr_push_ipv4address(struct ndr_push *ndr, int ndr_flags, const char *address) +_PUBLIC_ enum ndr_err_code ndr_push_ipv4address(struct ndr_push *ndr, int ndr_flags, const char *address) { uint32_t addr; if (!is_ipaddress(address)) { @@ -605,7 +605,7 @@ _PUBLIC_ NTSTATUS ndr_push_ipv4address(struct ndr_push *ndr, int ndr_flags, cons } addr = inet_addr(address); NDR_CHECK(ndr_push_uint32(ndr, ndr_flags, htonl(addr))); - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /* @@ -794,7 +794,7 @@ _PUBLIC_ void ndr_print_DATA_BLOB(struct ndr_print *ndr, const char *name, DATA_ /* push a DATA_BLOB onto the wire. */ -_PUBLIC_ NTSTATUS ndr_push_DATA_BLOB(struct ndr_push *ndr, int ndr_flags, DATA_BLOB blob) +_PUBLIC_ enum ndr_err_code ndr_push_DATA_BLOB(struct ndr_push *ndr, int ndr_flags, DATA_BLOB blob) { if (ndr->flags & LIBNDR_ALIGN_FLAGS) { if (ndr->flags & LIBNDR_FLAG_ALIGN2) { @@ -810,13 +810,13 @@ _PUBLIC_ NTSTATUS ndr_push_DATA_BLOB(struct ndr_push *ndr, int ndr_flags, DATA_B NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, blob.length)); } NDR_CHECK(ndr_push_bytes(ndr, blob.data, blob.length)); - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } /* pull a DATA_BLOB from the wire. */ -_PUBLIC_ NTSTATUS ndr_pull_DATA_BLOB(struct ndr_pull *ndr, int ndr_flags, DATA_BLOB *blob) +_PUBLIC_ enum ndr_err_code ndr_pull_DATA_BLOB(struct ndr_pull *ndr, int ndr_flags, DATA_BLOB *blob) { uint32_t length = 0; @@ -839,7 +839,7 @@ _PUBLIC_ NTSTATUS ndr_pull_DATA_BLOB(struct ndr_pull *ndr, int ndr_flags, DATA_B NDR_PULL_NEED_BYTES(ndr, length); *blob = data_blob_talloc(ndr->current_mem_ctx, ndr->data+ndr->offset, length); ndr->offset += length; - return NT_STATUS_OK; + return NDR_ERR_SUCCESS; } _PUBLIC_ uint32_t ndr_size_DATA_BLOB(int ret, const DATA_BLOB *data, int flags) -- cgit From e399a606f512df15316bc5e804384ffa475ca446 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 20 Nov 2007 11:08:33 +0100 Subject: r26054: ndr: remove ndr_push/pull_save Using a uint32_t offset is all we need metze (This used to be commit 2c06b48a858016f9329dcd73231fb3c7b711a918) --- source4/librpc/ndr/ndr_basic.c | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 0ef78a2a54..93a177f94e 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -446,22 +446,6 @@ _PUBLIC_ enum ndr_err_code ndr_push_array_uint8(struct ndr_push *ndr, int ndr_fl return ndr_push_bytes(ndr, data, n); } -/* - save the current position - */ -_PUBLIC_ void ndr_push_save(struct ndr_push *ndr, struct ndr_push_save *save) -{ - save->offset = ndr->offset; -} - -/* - restore the position - */ -_PUBLIC_ void ndr_push_restore(struct ndr_push *ndr, struct ndr_push_save *save) -{ - ndr->offset = save->offset; -} - /* push a unique non-zero value if a pointer is non-NULL, otherwise 0 */ -- cgit From 107ab090e23dfc517bc74bb553315cd3528e1f7d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 17 Apr 2008 14:47:07 +0200 Subject: use uintptr_t instead of intptr_t where appropriate (This used to be commit d62f2bcc85c13605c133db250e0a86d2d6ccc481) --- source4/librpc/ndr/ndr_basic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 93a177f94e..1d2b47c850 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -196,7 +196,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_hyper(struct ndr_pull *ndr, int ndr_flags, u */ _PUBLIC_ enum ndr_err_code ndr_pull_pointer(struct ndr_pull *ndr, int ndr_flags, void* *v) { - intptr_t h; + uintptr_t h; NDR_PULL_ALIGN(ndr, sizeof(h)); NDR_PULL_NEED_BYTES(ndr, sizeof(h)); memcpy(&h, ndr->data+ndr->offset, sizeof(h)); @@ -393,7 +393,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_hyper(struct ndr_push *ndr, int ndr_flags, u */ _PUBLIC_ enum ndr_err_code ndr_push_pointer(struct ndr_push *ndr, int ndr_flags, void* v) { - intptr_t h = (intptr_t)v; + uintptr_t h = (intptr_t)v; NDR_PUSH_ALIGN(ndr, sizeof(h)); NDR_PUSH_NEED_BYTES(ndr, sizeof(h)); memcpy(ndr->data+ndr->offset, &h, sizeof(h)); -- cgit