[SCM] Samba Shared Repository - branch master updated

Andrew Tridgell tridge at samba.org
Wed Sep 7 21:03:02 MDT 2011


The branch, master has been updated
       via  e0c5f1c s4-cracknames: use consistent search for crossRef objects
       via  dd80fc6 pidl: adjust expected output for new flag checking
       via  de318e5 s4-dsdb: prevent crash on bad DN in construct_parent_guid()
       via  ad4ce31 torture-drs: fixed NDR tests for DRS blobs
       via  bf8dd20 torture-ndr: fixed NDR tests for NTLMSSP blobs
       via  7416da6 torture-ndr: fixed NDR tests for NBT blobs
       via  d49f067 torture-ndr: fixed NDR tests for DFS blobs
       via  430123e torture-ndr: added support for testing push functions
       via  3d5dd91 pidl: added checking of NDR flags in generated code
       via  a19fd96 libndr: add checking to all pull/push functions of base types
       via  1c25f5e libndr: moved the NDR_* flags to have less overlap
       via  6e25723 lib: added base64_decode_data_blob_talloc()
       via  1e9573f s4-dsdb: fixed compiler warning
      from  0aa6751 Tidy up previous patch for bug #8442 - NFSv4 DENY ACLs always include SYNCHRONIZE flag - blocking renames.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit e0c5f1c1ab2db6042112ee445941b04ae162e778
Author: Andrew Tridgell <tridge at samba.org>
Date:   Wed Sep 7 17:18:24 2011 +1000

    s4-cracknames: use consistent search for crossRef objects
    
    This matches the search in other places
    
    Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>
    
    Autobuild-User: Andrew Tridgell <tridge at samba.org>
    Autobuild-Date: Thu Sep  8 05:02:54 CEST 2011 on sn-devel-104

commit dd80fc60fd954a3bee86831e887135c4be7ea3fd
Author: Andrew Tridgell <tridge at samba.org>
Date:   Wed Sep 7 17:12:37 2011 +1000

    pidl: adjust expected output for new flag checking

commit de318e58b01696e7aea39d14da099dbb4173c055
Author: Andrew Tridgell <tridge at samba.org>
Date:   Wed Sep 7 16:25:48 2011 +1000

    s4-dsdb: prevent crash on bad DN in construct_parent_guid()
    
    this was found by a flakey test in autobuild

commit ad4ce31e86fecf27297c40c80404f85a150ab799
Author: Andrew Tridgell <tridge at samba.org>
Date:   Wed Sep 7 15:37:22 2011 +1000

    torture-drs: fixed NDR tests for DRS blobs
    
    this also adds new tests for trustAuthInOutBlob blobs
    
    Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>

commit bf8dd20bddd1fca3e4caf59bf3253c70530850b7
Author: Andrew Tridgell <tridge at samba.org>
Date:   Wed Sep 7 15:36:57 2011 +1000

    torture-ndr: fixed NDR tests for NTLMSSP blobs
    
    Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>

commit 7416da636d91f0c8ae559dc02e5b6cbcabc8779d
Author: Andrew Tridgell <tridge at samba.org>
Date:   Wed Sep 7 15:36:38 2011 +1000

    torture-ndr: fixed NDR tests for NBT blobs
    
    Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>

commit d49f0676d07a5e27c6a1a7441f91f9b474222529
Author: Andrew Tridgell <tridge at samba.org>
Date:   Wed Sep 7 15:36:22 2011 +1000

    torture-ndr: fixed NDR tests for DFS blobs
    
    Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>

commit 430123e84e099f78ba794fdbf7de30d1169cd0cb
Author: Andrew Tridgell <tridge at samba.org>
Date:   Wed Sep 7 15:35:55 2011 +1000

    torture-ndr: added support for testing push functions
    
    this allows us to check the symmetry of pull/push functions in NDR
    tests
    
    Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>

commit 3d5dd91f598b8661d090ae147ae7c3a8fcea29e0
Author: Andrew Tridgell <tridge at samba.org>
Date:   Wed Sep 7 15:34:43 2011 +1000

    pidl: added checking of NDR flags in generated code
    
    Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>

commit a19fd96ab87290cd6ed1c93cd8f83e8697592b21
Author: Andrew Tridgell <tridge at samba.org>
Date:   Wed Sep 7 15:34:20 2011 +1000

    libndr: add checking to all pull/push functions of base types
    
    this checks that the passed in ndr_flags are valid
    
    Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>

commit 1c25f5ebca7eb4e8a6ce95b1adf6088d67aecb94
Author: Andrew Tridgell <tridge at samba.org>
Date:   Wed Sep 7 15:29:32 2011 +1000

    libndr: moved the NDR_* flags to have less overlap
    
    We have 3 different types of flags values in our NDR layer. We've
    recently found bugs where these types of flags have been mixed up,
    especially by people adding hand written ndr code for tricky
    structures. We previously got away with this because (for example)
    NDR_SCALARS and NDR_IN had the same value, so mixing up the two
    concepts sometimes worked. Unfortunately it also led to bugs where we
    didn't do what was expected, such as in our smbtorture ndr test suite,
    where passing a ndr_flags value of zero led to only checking that two
    empty structures were equal.
    
    This changes the values of the NDR_IN|NDR_OUT and
    NDR_SCALARS|NDR_BUFFERS values to be in different bit ranges, and adds
    macros for checking the validity of passed in flags. A followup patch
    modifies the ndr calls to use these macros, and pidl to generate
    them. This should catch misuse of the APIs.
    
    Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>

commit 6e25723c82eced9eff8c06bd645b754008824370
Author: Andrew Tridgell <tridge at samba.org>
Date:   Wed Sep 7 15:28:42 2011 +1000

    lib: added base64_decode_data_blob_talloc()
    
    its nice to be able to allocate on other than NULL
    
    Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>

commit 1e9573fe4d6204a0c9b790f290e1a3763e2d980f
Author: Andrew Tridgell <tridge at samba.org>
Date:   Mon Sep 5 17:07:22 2011 +1000

    s4-dsdb: fixed compiler warning
    
    sid can be const
    
    Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 lib/util/base64.c                            |   13 ++++++-
 lib/util/util.h                              |    8 ++++
 librpc/ndr/libndr.h                          |   44 ++++++++++++++++++----
 librpc/ndr/ndr_basic.c                       |   34 +++++++++++++++++
 pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm     |    8 ++++
 pidl/tests/samba-ndr.pl                      |    6 ++-
 source4/dsdb/common/util.c                   |    2 +-
 source4/dsdb/samdb/cracknames.c              |    6 ++-
 source4/dsdb/samdb/ldb_modules/operational.c |    3 ++
 source4/torture/ndr/dfsblob.c                |    6 ++--
 source4/torture/ndr/drsblobs.c               |   42 ++++++++++++++++++++-
 source4/torture/ndr/nbt.c                    |    4 +-
 source4/torture/ndr/ndr.c                    |   50 +++++++++++++++++--------
 source4/torture/ndr/ndr.h                    |   27 +++++++++-----
 source4/torture/ndr/ntlmssp.c                |    9 +++--
 15 files changed, 211 insertions(+), 51 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/util/base64.c b/lib/util/base64.c
index 19ce2d1..bc78404 100644
--- a/lib/util/base64.c
+++ b/lib/util/base64.c
@@ -29,10 +29,10 @@ static const char b64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0
 /**
  * Decode a base64 string into a DATA_BLOB - simple and slow algorithm
  **/
-_PUBLIC_ DATA_BLOB base64_decode_data_blob(const char *s)
+_PUBLIC_ DATA_BLOB base64_decode_data_blob_talloc(TALLOC_CTX *mem_ctx, const char *s)
 {
 	int bit_offset, byte_offset, idx, i, n;
-	DATA_BLOB decoded = data_blob(s, strlen(s)+1);
+	DATA_BLOB decoded = data_blob_talloc(mem_ctx, s, strlen(s)+1);
 	unsigned char *d = decoded.data;
 	char *p;
 
@@ -61,10 +61,19 @@ _PUBLIC_ DATA_BLOB base64_decode_data_blob(const char *s)
 
 	/* fix up length */
 	decoded.length = n;
+	decoded.data = talloc_realloc(mem_ctx, decoded.data, uint8_t, n);
 	return decoded;
 }
 
 /**
+ * Decode a base64 string into a DATA_BLOB - simple and slow algorithm
+ **/
+_PUBLIC_ DATA_BLOB base64_decode_data_blob(const char *s)
+{
+	return base64_decode_data_blob_talloc(NULL, s);
+}
+
+/**
  * Decode a base64 string in-place - wrapper for the above
  **/
 _PUBLIC_ void base64_decode_inplace(char *s)
diff --git a/lib/util/util.h b/lib/util/util.h
index 0102fea..9a76fa9 100644
--- a/lib/util/util.h
+++ b/lib/util/util.h
@@ -412,7 +412,15 @@ _PUBLIC_ void string_replace(char *s, char oldc, char newc);
 /**
  Base64 decode a string, place into a data blob.  Caller to data_blob_free() the result.
 **/
+_PUBLIC_ DATA_BLOB base64_decode_data_blob_talloc(TALLOC_CTX *mem_ctx, const char *s);
+
+/**
+ Base64 decode a string, place into a data blob on NULL context.
+ Caller to data_blob_free() the result.
+**/
 _PUBLIC_ DATA_BLOB base64_decode_data_blob(const char *s);
+
+
 /**
  Base64 decode a string, inplace
 **/
diff --git a/librpc/ndr/libndr.h b/librpc/ndr/libndr.h
index 1f65ab4..c8edfda 100644
--- a/librpc/ndr/libndr.h
+++ b/librpc/ndr/libndr.h
@@ -192,7 +192,8 @@ enum ndr_err_code {
 	NDR_ERR_IPV6ADDRESS,
 	NDR_ERR_INVALID_POINTER,
 	NDR_ERR_UNREAD_BYTES,
-	NDR_ERR_NDR64
+	NDR_ERR_NDR64,
+	NDR_ERR_FLAGS
 };
 
 #define NDR_ERR_CODE_IS_SUCCESS(x) (x == NDR_ERR_SUCCESS)
@@ -210,17 +211,44 @@ enum ndr_compression_alg {
 
 /*
   flags passed to control parse flow
+  These are deliberately in a different range to the NDR_IN/NDR_OUT
+  flags to catch mixups
 */
-#define NDR_SCALARS 1
-#define NDR_BUFFERS 2
+#define NDR_SCALARS    0x100
+#define NDR_BUFFERS    0x200
 
 /*
-  flags passed to ndr_print_*()
+  flags passed to ndr_print_*() and ndr pull/push for functions
+  These are deliberately in a different range to the NDR_SCALARS/NDR_BUFFERS
+  flags to catch mixups
 */
-#define NDR_IN 1
-#define NDR_OUT 2
-#define NDR_BOTH 3
-#define NDR_SET_VALUES 4
+#define NDR_IN         0x10
+#define NDR_OUT        0x20
+#define NDR_BOTH       0x30
+#define NDR_SET_VALUES 0x40
+
+
+#define NDR_PULL_CHECK_FLAGS(ndr, ndr_flags) do { \
+	if ((ndr_flags) & ~(NDR_SCALARS|NDR_BUFFERS)) { \
+		return ndr_pull_error(ndr, NDR_ERR_FLAGS, "Invalid pull struct ndr_flags 0x%x", ndr_flags); \
+	} \
+} while (0)
+
+#define NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags) do { \
+	if ((ndr_flags) & ~(NDR_SCALARS|NDR_BUFFERS)) \
+		return ndr_push_error(ndr, NDR_ERR_FLAGS, "Invalid push struct ndr_flags 0x%x", ndr_flags); \
+} while (0)
+
+#define NDR_PULL_CHECK_FN_FLAGS(ndr, flags) do { \
+	if ((flags) & ~(NDR_BOTH|NDR_SET_VALUES)) { \
+		return ndr_pull_error(ndr, NDR_ERR_FLAGS, "Invalid fn pull flags 0x%x", flags); \
+	} \
+} while (0)
+
+#define NDR_PUSH_CHECK_FN_FLAGS(ndr, flags) do { \
+	if ((flags) & ~(NDR_BOTH|NDR_SET_VALUES)) \
+		return ndr_push_error(ndr, NDR_ERR_FLAGS, "Invalid fn push flags 0x%x", flags); \
+} while (0)
 
 #define NDR_PULL_NEED_BYTES(ndr, n) do { \
 	if (unlikely((n) > ndr->data_size || ndr->offset + (n) > ndr->data_size)) { \
diff --git a/librpc/ndr/ndr_basic.c b/librpc/ndr/ndr_basic.c
index b444300..ab234bf 100644
--- a/librpc/ndr/ndr_basic.c
+++ b/librpc/ndr/ndr_basic.c
@@ -61,6 +61,7 @@ _PUBLIC_ void ndr_check_padding(struct ndr_pull *ndr, size_t n)
 */
 _PUBLIC_ enum ndr_err_code ndr_pull_int8(struct ndr_pull *ndr, int ndr_flags, int8_t *v)
 {
+	NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
 	NDR_PULL_NEED_BYTES(ndr, 1);
 	*v = (int8_t)CVAL(ndr->data, ndr->offset);
 	ndr->offset += 1;
@@ -72,6 +73,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_int8(struct ndr_pull *ndr, int ndr_flags, in
 */
 _PUBLIC_ enum ndr_err_code ndr_pull_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *v)
 {
+	NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
 	NDR_PULL_NEED_BYTES(ndr, 1);
 	*v = CVAL(ndr->data, ndr->offset);
 	ndr->offset += 1;
@@ -83,6 +85,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_uint8(struct ndr_pull *ndr, int ndr_flags, u
 */
 _PUBLIC_ enum ndr_err_code ndr_pull_int16(struct ndr_pull *ndr, int ndr_flags, int16_t *v)
 {
+	NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
 	NDR_PULL_ALIGN(ndr, 2);
 	NDR_PULL_NEED_BYTES(ndr, 2);
 	*v = (uint16_t)NDR_SVAL(ndr, ndr->offset);
@@ -95,6 +98,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_int16(struct ndr_pull *ndr, int ndr_flags, i
 */
 _PUBLIC_ enum ndr_err_code ndr_pull_uint16(struct ndr_pull *ndr, int ndr_flags, uint16_t *v)
 {
+	NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
 	NDR_PULL_ALIGN(ndr, 2);
 	NDR_PULL_NEED_BYTES(ndr, 2);
 	*v = NDR_SVAL(ndr, ndr->offset);
@@ -107,6 +111,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_uint16(struct ndr_pull *ndr, int ndr_flags,
 */
 _PUBLIC_ enum ndr_err_code ndr_pull_uint1632(struct ndr_pull *ndr, int ndr_flags, uint16_t *v)
 {
+	NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
 	if (unlikely(ndr->flags & LIBNDR_FLAG_NDR64)) {
 		uint32_t v32 = 0;
 		enum ndr_err_code err = ndr_pull_uint32(ndr, ndr_flags, &v32);
@@ -125,6 +130,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_uint1632(struct ndr_pull *ndr, int ndr_flags
 */
 _PUBLIC_ enum ndr_err_code ndr_pull_int32(struct ndr_pull *ndr, int ndr_flags, int32_t *v)
 {
+	NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
 	NDR_PULL_ALIGN(ndr, 4);
 	NDR_PULL_NEED_BYTES(ndr, 4);
 	*v = NDR_IVALS(ndr, ndr->offset);
@@ -137,6 +143,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_int32(struct ndr_pull *ndr, int ndr_flags, i
 */
 _PUBLIC_ enum ndr_err_code ndr_pull_uint32(struct ndr_pull *ndr, int ndr_flags, uint32_t *v)
 {
+	NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
 	NDR_PULL_ALIGN(ndr, 4);
 	NDR_PULL_NEED_BYTES(ndr, 4);
 	*v = NDR_IVAL(ndr, ndr->offset);
@@ -151,6 +158,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_uint3264(struct ndr_pull *ndr, int ndr_flags
 {
 	uint64_t v64;
 	enum ndr_err_code err;
+	NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
 	if (likely(!(ndr->flags & LIBNDR_FLAG_NDR64))) {
 		return ndr_pull_uint32(ndr, ndr_flags, v);
 	}
@@ -169,6 +177,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_uint3264(struct ndr_pull *ndr, int ndr_flags
 */
 _PUBLIC_ enum ndr_err_code ndr_pull_double(struct ndr_pull *ndr, int ndr_flags, double *v)
 {
+	NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
 	NDR_PULL_ALIGN(ndr, 8);
 	NDR_PULL_NEED_BYTES(ndr, 8);
 	memcpy(v, ndr->data+ndr->offset, 8);
@@ -217,6 +226,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_ref_ptr(struct ndr_pull *ndr, uint32_t *v)
 */
 _PUBLIC_ enum ndr_err_code ndr_pull_udlong(struct ndr_pull *ndr, int ndr_flags, uint64_t *v)
 {
+	NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
 	NDR_PULL_ALIGN(ndr, 4);
 	NDR_PULL_NEED_BYTES(ndr, 8);
 	*v = NDR_IVAL(ndr, ndr->offset);
@@ -230,6 +240,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_udlong(struct ndr_pull *ndr, int ndr_flags,
 */
 _PUBLIC_ enum ndr_err_code ndr_pull_udlongr(struct ndr_pull *ndr, int ndr_flags, uint64_t *v)
 {
+	NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
 	NDR_PULL_ALIGN(ndr, 4);
 	NDR_PULL_NEED_BYTES(ndr, 8);
 	*v = ((uint64_t)NDR_IVAL(ndr, ndr->offset)) << 32;
@@ -264,6 +275,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)
 {
 	uintptr_t h;
+	NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
 	NDR_PULL_ALIGN(ndr, sizeof(h));
 	NDR_PULL_NEED_BYTES(ndr, sizeof(h));
 	memcpy(&h, ndr->data+ndr->offset, sizeof(h));
@@ -278,6 +290,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_pointer(struct ndr_pull *ndr, int ndr_flags,
 _PUBLIC_ enum ndr_err_code ndr_pull_NTSTATUS(struct ndr_pull *ndr, int ndr_flags, NTSTATUS *status)
 {
 	uint32_t v;
+	NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
 	NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v));
 	*status = NT_STATUS(v);
 	return NDR_ERR_SUCCESS;
@@ -302,6 +315,7 @@ _PUBLIC_ void ndr_print_NTSTATUS(struct ndr_print *ndr, const char *name, NTSTAT
 _PUBLIC_ enum ndr_err_code ndr_pull_WERROR(struct ndr_pull *ndr, int ndr_flags, WERROR *status)
 {
 	uint32_t v;
+	NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
 	NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v));
 	*status = W_ERROR(v);
 	return NDR_ERR_SUCCESS;
@@ -414,6 +428,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_bytes(struct ndr_pull *ndr, uint8_t *data, u
 */
 _PUBLIC_ enum ndr_err_code ndr_pull_array_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *data, uint32_t n)
 {
+	NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
 	if (!(ndr_flags & NDR_SCALARS)) {
 		return NDR_ERR_SUCCESS;
 	}
@@ -425,6 +440,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_array_uint8(struct ndr_pull *ndr, int ndr_fl
 */
 _PUBLIC_ enum ndr_err_code ndr_push_int8(struct ndr_push *ndr, int ndr_flags, int8_t v)
 {
+	NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
 	NDR_PUSH_NEED_BYTES(ndr, 1);
 	SCVAL(ndr->data, ndr->offset, (uint8_t)v);
 	ndr->offset += 1;
@@ -436,6 +452,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_int8(struct ndr_push *ndr, int ndr_flags, in
 */
 _PUBLIC_ enum ndr_err_code ndr_push_uint8(struct ndr_push *ndr, int ndr_flags, uint8_t v)
 {
+	NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
 	NDR_PUSH_NEED_BYTES(ndr, 1);
 	SCVAL(ndr->data, ndr->offset, v);
 	ndr->offset += 1;
@@ -447,6 +464,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_uint8(struct ndr_push *ndr, int ndr_flags, u
 */
 _PUBLIC_ enum ndr_err_code ndr_push_int16(struct ndr_push *ndr, int ndr_flags, int16_t v)
 {
+	NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
 	NDR_PUSH_ALIGN(ndr, 2);
 	NDR_PUSH_NEED_BYTES(ndr, 2);
 	NDR_SSVAL(ndr, ndr->offset, (uint16_t)v);
@@ -459,6 +477,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_int16(struct ndr_push *ndr, int ndr_flags, i
 */
 _PUBLIC_ enum ndr_err_code ndr_push_uint16(struct ndr_push *ndr, int ndr_flags, uint16_t v)
 {
+	NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
 	NDR_PUSH_ALIGN(ndr, 2);
 	NDR_PUSH_NEED_BYTES(ndr, 2);
 	NDR_SSVAL(ndr, ndr->offset, v);
@@ -482,6 +501,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_uint1632(struct ndr_push *ndr, int ndr_flags
 */
 _PUBLIC_ enum ndr_err_code ndr_push_int32(struct ndr_push *ndr, int ndr_flags, int32_t v)
 {
+	NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
 	NDR_PUSH_ALIGN(ndr, 4);
 	NDR_PUSH_NEED_BYTES(ndr, 4);
 	NDR_SIVALS(ndr, ndr->offset, v);
@@ -494,6 +514,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_int32(struct ndr_push *ndr, int ndr_flags, i
 */
 _PUBLIC_ enum ndr_err_code ndr_push_uint32(struct ndr_push *ndr, int ndr_flags, uint32_t v)
 {
+	NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
 	NDR_PUSH_ALIGN(ndr, 4);
 	NDR_PUSH_NEED_BYTES(ndr, 4);
 	NDR_SIVAL(ndr, ndr->offset, v);
@@ -517,6 +538,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_uint3264(struct ndr_push *ndr, int ndr_flags
 */
 _PUBLIC_ enum ndr_err_code ndr_push_udlong(struct ndr_push *ndr, int ndr_flags, uint64_t v)
 {
+	NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
 	NDR_PUSH_ALIGN(ndr, 4);
 	NDR_PUSH_NEED_BYTES(ndr, 8);
 	NDR_SIVAL(ndr, ndr->offset, (v & 0xFFFFFFFF));
@@ -530,6 +552,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_udlong(struct ndr_push *ndr, int ndr_flags,
 */
 _PUBLIC_ enum ndr_err_code ndr_push_udlongr(struct ndr_push *ndr, int ndr_flags, uint64_t v)
 {
+	NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
 	NDR_PUSH_ALIGN(ndr, 4);
 	NDR_PUSH_NEED_BYTES(ndr, 8);
 	NDR_SIVAL(ndr, ndr->offset, (v>>32));
@@ -563,6 +586,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_hyper(struct ndr_push *ndr, int ndr_flags, u
 */
 _PUBLIC_ enum ndr_err_code ndr_push_double(struct ndr_push *ndr, int ndr_flags, double v)
 {
+	NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
 	NDR_PUSH_ALIGN(ndr, 8);
 	NDR_PUSH_NEED_BYTES(ndr, 8);
 	memcpy(ndr->data+ndr->offset, &v, 8);
@@ -576,6 +600,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_double(struct ndr_push *ndr, int ndr_flags,
 _PUBLIC_ enum ndr_err_code ndr_push_pointer(struct ndr_push *ndr, int ndr_flags, void* v)
 {
 	uintptr_t h = (intptr_t)v;
+	NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
 	NDR_PUSH_ALIGN(ndr, sizeof(h));
 	NDR_PUSH_NEED_BYTES(ndr, sizeof(h));
 	memcpy(ndr->data+ndr->offset, &h, sizeof(h));
@@ -686,6 +711,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_zero(struct ndr_push *ndr, 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)
 {
+	NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
 	if (!(ndr_flags & NDR_SCALARS)) {
 		return NDR_ERR_SUCCESS;
 	}
@@ -738,6 +764,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_ref_ptr(struct ndr_push *ndr)
 */
 _PUBLIC_ enum ndr_err_code ndr_push_NTTIME(struct ndr_push *ndr, int ndr_flags, NTTIME t)
 {
+	NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
 	NDR_CHECK(ndr_push_udlong(ndr, ndr_flags, t));
 	return NDR_ERR_SUCCESS;
 }
@@ -747,6 +774,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_NTTIME(struct ndr_push *ndr, int ndr_flags,
 */
 _PUBLIC_ enum ndr_err_code ndr_pull_NTTIME(struct ndr_pull *ndr, int ndr_flags, NTTIME *t)
 {
+	NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
 	NDR_CHECK(ndr_pull_udlong(ndr, ndr_flags, t));
 	return NDR_ERR_SUCCESS;
 }
@@ -756,6 +784,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_NTTIME(struct ndr_pull *ndr, int ndr_flags,
 */
 _PUBLIC_ enum ndr_err_code ndr_push_NTTIME_1sec(struct ndr_push *ndr, int ndr_flags, NTTIME t)
 {
+	NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
 	t /= 10000000;
 	NDR_CHECK(ndr_push_hyper(ndr, ndr_flags, t));
 	return NDR_ERR_SUCCESS;
@@ -766,6 +795,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_NTTIME_1sec(struct ndr_push *ndr, int ndr_fl
 */
 _PUBLIC_ enum ndr_err_code ndr_pull_NTTIME_1sec(struct ndr_pull *ndr, int ndr_flags, NTTIME *t)
 {
+	NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
 	NDR_CHECK(ndr_pull_hyper(ndr, ndr_flags, t));
 	(*t) *= 10000000;
 	return NDR_ERR_SUCCESS;
@@ -776,6 +806,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_NTTIME_1sec(struct ndr_pull *ndr, int ndr_fl
 */
 _PUBLIC_ enum ndr_err_code ndr_pull_NTTIME_hyper(struct ndr_pull *ndr, int ndr_flags, NTTIME *t)
 {
+	NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
 	NDR_CHECK(ndr_pull_hyper(ndr, ndr_flags, t));
 	return NDR_ERR_SUCCESS;
 }
@@ -785,6 +816,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_NTTIME_hyper(struct ndr_pull *ndr, int ndr_f
 */
 _PUBLIC_ enum ndr_err_code ndr_push_NTTIME_hyper(struct ndr_push *ndr, int ndr_flags, NTTIME t)
 {
+	NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
 	NDR_CHECK(ndr_push_hyper(ndr, ndr_flags, t));
 	return NDR_ERR_SUCCESS;
 }
@@ -814,6 +846,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_time_t(struct ndr_pull *ndr, int ndr_flags,
 */
 _PUBLIC_ enum ndr_err_code ndr_push_uid_t(struct ndr_push *ndr, int ndr_flags, uid_t u)
 {
+	NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
 	return ndr_push_hyper(ndr, NDR_SCALARS, (uint64_t)u);
 }
 
@@ -839,6 +872,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_uid_t(struct ndr_pull *ndr, int ndr_flags, u
 */
 _PUBLIC_ enum ndr_err_code ndr_push_gid_t(struct ndr_push *ndr, int ndr_flags, gid_t g)
 {
+	NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
 	return ndr_push_hyper(ndr, NDR_SCALARS, (uint64_t)g);
 }
 
diff --git a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
index 3d31366..19c3cc8 100644
--- a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
@@ -1332,6 +1332,7 @@ sub ParseStructPush($$$$)
 
 	$self->start_flags($struct, $ndr);
 
+	$self->pidl("NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);");
 	$self->pidl("if (ndr_flags & NDR_SCALARS) {");
 	$self->indent;
 	$self->ParseStructPushPrimitives($struct, $ndr, $varname, $env);
@@ -1645,6 +1646,7 @@ sub ParseStructPull($$$$)
 
 	my $env = GenerateStructEnv($struct, $varname);
 
+	$self->pidl("NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);");
 	$self->pidl("if (ndr_flags & NDR_SCALARS) {");
 	$self->indent;
 	$self->ParseStructPullPrimitives($struct,$ndr,$varname,$env);
@@ -1808,6 +1810,7 @@ sub ParseUnionPush($$$$)
 
 	$self->start_flags($e, $ndr);
 
+	$self->pidl("NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);");
 	$self->pidl("if (ndr_flags & NDR_SCALARS) {");
 	$self->indent;
 	$self->ParseUnionPushPrimitives($e, $ndr, $varname);
@@ -1985,6 +1988,7 @@ sub ParseUnionPull($$$$)
 
 	$self->pidl("level = ndr_pull_get_switch_value($ndr, $varname);");
 
+	$self->pidl("NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);");
 	$self->pidl("if (ndr_flags & NDR_SCALARS) {");
 	$self->indent;
 	$self->ParseUnionPullPrimitives($e,$ndr,$varname,$switch_type);
@@ -2267,6 +2271,8 @@ sub ParseFunctionPush($$)
 		$self->DeclareArrayVariables($e);
 	}
 
+	$self->pidl("NDR_PUSH_CHECK_FN_FLAGS(ndr, flags);");
+
 	$self->pidl("if (flags & NDR_IN) {");
 	$self->indent;
 
@@ -2354,6 +2360,8 @@ sub ParseFunctionPull($$)
 		$double_cases{"$e->{NAME}"} = 1;
 	}
 
+	$self->pidl("NDR_PULL_CHECK_FN_FLAGS(ndr, flags);");
+
 	$self->pidl("if (flags & NDR_IN) {");
 	$self->indent;
 
diff --git a/pidl/tests/samba-ndr.pl b/pidl/tests/samba-ndr.pl
index e257817..7c53cbc 100755
--- a/pidl/tests/samba-ndr.pl
+++ b/pidl/tests/samba-ndr.pl
@@ -221,7 +221,8 @@ $generator->ParseStructPush({
 			PROPERTIES => {},
 			ALIGN => 4,
 			ELEMENTS => [ ]}, "ndr", "x");
-is($generator->{res}, "if (ndr_flags & NDR_SCALARS) {
+is($generator->{res}, "NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
+if (ndr_flags & NDR_SCALARS) {
 	NDR_CHECK(ndr_push_align(ndr, 4));
 	NDR_CHECK(ndr_push_trailer_align(ndr, 4));
 }
@@ -245,7 +246,8 @@ $generator->ParseStructPush({
 			ALIGN => 4,
 			SURROUNDING_ELEMENT => $e,
 			ELEMENTS => [ $e ]}, "ndr", "x");
-is($generator->{res}, "if (ndr_flags & NDR_SCALARS) {
+is($generator->{res}, "NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
+if (ndr_flags & NDR_SCALARS) {
 	NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, ndr_string_array_size(ndr, x->el1)));
 	NDR_CHECK(ndr_push_align(ndr, 4));
 	NDR_CHECK(ndr_push_mytype(ndr, NDR_SCALARS, &x->el1));
diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c
index f64e624..3276ec8 100644
--- a/source4/dsdb/common/util.c
+++ b/source4/dsdb/common/util.c
@@ -715,7 +715,7 @@ int samdb_find_or_add_attribute(struct ldb_context *ldb, struct ldb_message *msg
   add a dom_sid element to a message
 */
 int samdb_msg_add_dom_sid(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
-			 const char *attr_name, struct dom_sid *sid)
+			  const char *attr_name, const struct dom_sid *sid)
 {
 	struct ldb_val v;
 	enum ndr_err_code ndr_err;
diff --git a/source4/dsdb/samdb/cracknames.c b/source4/dsdb/samdb/cracknames.c
index 105de56..56655ff 100644
--- a/source4/dsdb/samdb/cracknames.c
+++ b/source4/dsdb/samdb/cracknames.c
@@ -442,8 +442,10 @@ WERROR DsCrackNameOneName(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ctx,
 		s[0] = '\0';
 		s++;
 
-		domain_filter = talloc_asprintf(mem_ctx, "(&(objectClass=crossRef)(ncName=%s))", 
-						ldb_dn_get_linearized(samdb_dns_domain_to_dn(sam_ctx, mem_ctx, str)));


-- 
Samba Shared Repository


More information about the samba-cvs mailing list