diff options
author | Stefan Metzmacher <metze@samba.org> | 2005-07-08 05:22:31 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:19:22 -0500 |
commit | 3d3a86f95d3b7533983450771a0b25894536ae6a (patch) | |
tree | 1c25047c5f7d684962d34d8d928ef7bd0a44660f /source4/librpc/ndr | |
parent | b7952f805872083da9ce233ef0d278f364a1c738 (diff) | |
download | samba-3d3a86f95d3b7533983450771a0b25894536ae6a.tar.gz samba-3d3a86f95d3b7533983450771a0b25894536ae6a.tar.bz2 samba-3d3a86f95d3b7533983450771a0b25894536ae6a.zip |
r8227: add STR_LARGE_SIZE flag, to support strings where the size is length+1,
metze
(This used to be commit cdd03fe87d0120ab3e18566bfc20df5955f9fb3c)
Diffstat (limited to 'source4/librpc/ndr')
-rw-r--r-- | source4/librpc/ndr/libndr.h | 3 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_string.c | 17 |
2 files changed, 18 insertions, 2 deletions
diff --git a/source4/librpc/ndr/libndr.h b/source4/librpc/ndr/libndr.h index 24cb80c994..2f99c75ce7 100644 --- a/source4/librpc/ndr/libndr.h +++ b/source4/librpc/ndr/libndr.h @@ -113,7 +113,8 @@ struct ndr_print { #define LIBNDR_FLAG_STR_CHARLEN (1<<11) #define LIBNDR_FLAG_STR_UTF8 (1<<12) #define LIBNDR_FLAG_STR_FIXLEN15 (1<<13) -#define LIBNDR_STRING_FLAGS (0x3FFC) +#define LIBNDR_FLAG_STR_LARGE_SIZE (1<<14) +#define LIBNDR_STRING_FLAGS (0x7FFC) #define LIBNDR_FLAG_REF_ALLOC (1<<20) diff --git a/source4/librpc/ndr/ndr_string.c b/source4/librpc/ndr/ndr_string.c index 008b58dab9..42316a8003 100644 --- a/source4/librpc/ndr/ndr_string.c +++ b/source4/librpc/ndr/ndr_string.c @@ -66,6 +66,7 @@ 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: + case LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_NOTERM|LIBNDR_FLAG_STR_LARGE_SIZE: NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &len1)); NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &ofs)); if (ofs != 0) { @@ -93,6 +94,18 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) } NDR_CHECK(ndr_pull_advance(ndr, (len2 + c_len_term)*byte_mul)); + if (ndr->flags & LIBNDR_FLAG_STR_LARGE_SIZE) { + if (len1 != 0 && len2 == 0) { + DEBUG(6,("len1[%u] != (len2[%u]) '%s'\n", len1, len2, as)); + } else if (len1 != (len2 + 1)) { + DEBUG(6,("len1[%u] != (len2[%u]+1) '%s'\n", len1, len2, as)); + } + } else { + if (len1 != len2) { + DEBUG(6,("len1[%u] != len2[%u] '%s'\n", len1, len2, as)); + } + } + /* this is a way of detecting if a string is sent with the wrong termination */ if (ndr->flags & LIBNDR_FLAG_STR_NOTERM) { @@ -331,7 +344,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, NDR_SCALARS, c_len)); + c_len_term = 0; + case LIBNDR_FLAG_STR_LEN4|LIBNDR_FLAG_STR_SIZE4|LIBNDR_FLAG_STR_NOTERM|LIBNDR_FLAG_STR_LARGE_SIZE: + 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)); NDR_PUSH_NEED_BYTES(ndr, c_len*byte_mul); |