summaryrefslogtreecommitdiff
path: root/source4/librpc
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2005-07-08 05:22:31 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:19:22 -0500
commit3d3a86f95d3b7533983450771a0b25894536ae6a (patch)
tree1c25047c5f7d684962d34d8d928ef7bd0a44660f /source4/librpc
parentb7952f805872083da9ce233ef0d278f364a1c738 (diff)
downloadsamba-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')
-rw-r--r--source4/librpc/idl/idl_types.h1
-rw-r--r--source4/librpc/ndr/libndr.h3
-rw-r--r--source4/librpc/ndr/ndr_string.c17
3 files changed, 19 insertions, 2 deletions
diff --git a/source4/librpc/idl/idl_types.h b/source4/librpc/idl/idl_types.h
index 21f4beb8e7..1a6371d8f9 100644
--- a/source4/librpc/idl/idl_types.h
+++ b/source4/librpc/idl/idl_types.h
@@ -10,6 +10,7 @@
#define STR_CONFORMANT LIBNDR_FLAG_STR_CONFORMANT
#define STR_CHARLEN LIBNDR_FLAG_STR_CHARLEN
#define STR_UTF8 LIBNDR_FLAG_STR_UTF8
+#define STR_LARGE_SIZE LIBNDR_FLAG_STR_LARGE_SIZE
/*
a UCS2 string prefixed with [size] [offset] [length], all 32 bits
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);