[SCM] Samba Shared Repository - branch master updated

Andreas Schneider asn at samba.org
Tue Nov 19 14:48:03 UTC 2019


The branch, master has been updated
       via  42ac80fb46c ndr: Include the caller location in ndr_{pull,push}_error() messages
       via  183da1f9fda witness.idl: Change array type in IDL for the print function
      from  c34ec003b7d utils: only compile test_oLschema2ldif if fmemopen exists

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


- Log -----------------------------------------------------------------
commit 42ac80fb46cfb485e8c4a26d455fa784fdd1daed
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sat Nov 16 08:54:42 2019 +1300

    ndr: Include the caller location in ndr_{pull,push}_error() messages
    
    This should aid in debugging NDR parse failures.
    
    Use the ABI bump to again exclude ndr_table_misc incorrectly
    added in ABI 0.2.1.
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    
    Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date(master): Tue Nov 19 14:47:46 UTC 2019 on sn-devel-184

commit 183da1f9fda6f58cdff5cefad133a86462d5942a
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Nov 18 16:02:39 2019 +1300

    witness.idl: Change array type in IDL for the print function
    
    It is important that the generated print function checks r->messages
    before de-referencing r->messages[num] as r->num can be non-zero
    while r->messages is NULL.
    
    There is not witness server in Samba and print functions are only
    used during debugging and ndrdump in any case.
    
    The change in the IDL does not change the header and the IDL
    function is already nopull,nopush so only the print function changes.
    
    Found by Douglas Bagnall using Honggfuzz and a new fuzzer for
    Samba's NDR layer.
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

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

Summary of changes:
 librpc/ABI/{ndr-0.2.0.sigs => ndr-1.0.0.sigs} |  4 ++--
 librpc/idl/witness.idl                        |  2 +-
 librpc/ndr/libndr.h                           | 28 +++++++++++++++++++++------
 librpc/ndr/ndr.c                              | 28 +++++++++++++++++++--------
 librpc/wscript_build                          |  4 ++--
 pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm      |  4 ++--
 6 files changed, 49 insertions(+), 21 deletions(-)
 copy librpc/ABI/{ndr-0.2.0.sigs => ndr-1.0.0.sigs} (98%)


Changeset truncated at 500 lines:

diff --git a/librpc/ABI/ndr-0.2.0.sigs b/librpc/ABI/ndr-1.0.0.sigs
similarity index 98%
copy from librpc/ABI/ndr-0.2.0.sigs
copy to librpc/ABI/ndr-1.0.0.sigs
index 6346f2fb491..ffb3d0763fc 100644
--- a/librpc/ABI/ndr-0.2.0.sigs
+++ b/librpc/ABI/ndr-1.0.0.sigs
@@ -11,6 +11,8 @@ GUID_string: char *(TALLOC_CTX *, const struct GUID *)
 GUID_string2: char *(TALLOC_CTX *, const struct GUID *)
 GUID_to_ndr_blob: NTSTATUS (const struct GUID *, TALLOC_CTX *, DATA_BLOB *)
 GUID_zero: struct GUID (void)
+_ndr_pull_error: enum ndr_err_code (struct ndr_pull *, enum ndr_err_code, const char *, const char *, const char *, ...)
+_ndr_push_error: enum ndr_err_code (struct ndr_push *, enum ndr_err_code, const char *, const char *, const char *, ...)
 ndr_align_size: size_t (uint32_t, size_t)
 ndr_charset_length: uint32_t (const void *, charset_t)
 ndr_check_array_length: enum ndr_err_code (struct ndr_pull *, void *, uint32_t)
@@ -112,7 +114,6 @@ ndr_pull_enum_uint16: enum ndr_err_code (struct ndr_pull *, int, uint16_t *)
 ndr_pull_enum_uint1632: enum ndr_err_code (struct ndr_pull *, int, uint16_t *)
 ndr_pull_enum_uint32: enum ndr_err_code (struct ndr_pull *, int, uint32_t *)
 ndr_pull_enum_uint8: enum ndr_err_code (struct ndr_pull *, int, uint8_t *)
-ndr_pull_error: enum ndr_err_code (struct ndr_pull *, enum ndr_err_code, const char *, ...)
 ndr_pull_generic_ptr: enum ndr_err_code (struct ndr_pull *, uint32_t *)
 ndr_pull_get_relative_base_offset: uint32_t (struct ndr_pull *)
 ndr_pull_get_switch_value: uint32_t (struct ndr_pull *, const void *)
@@ -186,7 +187,6 @@ ndr_push_enum_uint16: enum ndr_err_code (struct ndr_push *, int, uint16_t)
 ndr_push_enum_uint1632: enum ndr_err_code (struct ndr_push *, int, uint16_t)
 ndr_push_enum_uint32: enum ndr_err_code (struct ndr_push *, int, uint32_t)
 ndr_push_enum_uint8: enum ndr_err_code (struct ndr_push *, int, uint8_t)
-ndr_push_error: enum ndr_err_code (struct ndr_push *, enum ndr_err_code, const char *, ...)
 ndr_push_expand: enum ndr_err_code (struct ndr_push *, uint32_t)
 ndr_push_full_ptr: enum ndr_err_code (struct ndr_push *, const void *)
 ndr_push_get_relative_base_offset: uint32_t (struct ndr_push *)
diff --git a/librpc/idl/witness.idl b/librpc/idl/witness.idl
index 1557badeb24..e230a5ea709 100644
--- a/librpc/idl/witness.idl
+++ b/librpc/idl/witness.idl
@@ -123,7 +123,7 @@ interface witness
 		witness_notifyResponse_type type;
 		[value(ndr_size_witness_notifyResponse(r, ndr->flags)-20)] uint32 length;
 		uint32 num;
-		[subcontext(4), subcontext_size(length), flag(NDR_REMAINING), switch_is(type)] witness_notifyResponse_message messages[num];
+	        [subcontext(4), subcontext_size(length), flag(NDR_REMAINING), switch_is(type), size_is(num)] witness_notifyResponse_message *messages;
 	} witness_notifyResponse;
 
 	[public] WERROR witness_AsyncNotify(
diff --git a/librpc/ndr/libndr.h b/librpc/ndr/libndr.h
index 8ece7374b9a..392ab76cc94 100644
--- a/librpc/ndr/libndr.h
+++ b/librpc/ndr/libndr.h
@@ -559,12 +559,28 @@ char *ndr_print_function_string(TALLOC_CTX *mem_ctx,
 				ndr_print_function_t fn, const char *name,
 				int flags, void *ptr);
 void ndr_set_flags(uint32_t *pflags, uint32_t new_flags);
-enum ndr_err_code ndr_pull_error(struct ndr_pull *ndr,
-				 enum ndr_err_code ndr_err,
-				 const char *format, ...) PRINTF_ATTRIBUTE(3,4);
-enum ndr_err_code ndr_push_error(struct ndr_push *ndr,
-				 enum ndr_err_code ndr_err,
-				 const char *format, ...)  PRINTF_ATTRIBUTE(3,4);
+enum ndr_err_code _ndr_pull_error(struct ndr_pull *ndr,
+				  enum ndr_err_code ndr_err,
+				  const char *function,
+				  const char *location,
+				  const char *format, ...) PRINTF_ATTRIBUTE(5,6);
+#define ndr_pull_error(ndr, ndr_err, ...) \
+	_ndr_pull_error(ndr, \
+		        ndr_err,      \
+		        __FUNCTION__, \
+		        __location__, \
+			__VA_ARGS__)
+enum ndr_err_code _ndr_push_error(struct ndr_push *ndr,
+				  enum ndr_err_code ndr_err,
+				  const char *function,
+				  const char *location,
+				  const char *format, ...)  PRINTF_ATTRIBUTE(5,6);
+#define ndr_push_error(ndr, ndr_err, ...) \
+	_ndr_push_error(ndr, \
+		        ndr_err, \
+		        __FUNCTION__, \
+		        __location__, \
+			__VA_ARGS__)
 enum ndr_err_code ndr_pull_subcontext_start(struct ndr_pull *ndr,
 				   struct ndr_pull **_subndr,
 				   size_t header_size,
diff --git a/librpc/ndr/ndr.c b/librpc/ndr/ndr.c
index d478eb69c01..53f9a816f94 100644
--- a/librpc/ndr/ndr.c
+++ b/librpc/ndr/ndr.c
@@ -587,9 +587,11 @@ _PUBLIC_ void ndr_set_flags(uint32_t *pflags, uint32_t new_flags)
 /*
   return and possibly log an NDR error
 */
-_PUBLIC_ enum ndr_err_code ndr_pull_error(struct ndr_pull *ndr,
-				 enum ndr_err_code ndr_err,
-				 const char *format, ...)
+_PUBLIC_ enum ndr_err_code _ndr_pull_error(struct ndr_pull *ndr,
+					   enum ndr_err_code ndr_err,
+					   const char *function,
+					   const char *location,
+					   const char *format, ...)
 {
 	char *s=NULL;
 	va_list ap;
@@ -612,7 +614,11 @@ _PUBLIC_ enum ndr_err_code ndr_pull_error(struct ndr_pull *ndr,
 		return NDR_ERR_ALLOC;
 	}
 
-	DEBUG(1,("ndr_pull_error(%u): %s\n", ndr_err, s));
+	D_WARNING("%s: ndr_pull_error(%s): %s at %s\n",
+		  function,
+		  ndr_map_error2string(ndr_err),
+		  s,
+		  location);
 
 	free(s);
 
@@ -622,9 +628,11 @@ _PUBLIC_ enum ndr_err_code ndr_pull_error(struct ndr_pull *ndr,
 /*
   return and possibly log an NDR error
 */
-_PUBLIC_ enum ndr_err_code ndr_push_error(struct ndr_push *ndr,
-				 enum ndr_err_code ndr_err,
-				 const char *format, ...)
+_PUBLIC_ enum ndr_err_code _ndr_push_error(struct ndr_push *ndr,
+					   enum ndr_err_code ndr_err,
+					   const char *function,
+					   const char *location,
+					   const char *format, ...)
 {
 	char *s=NULL;
 	va_list ap;
@@ -638,7 +646,11 @@ _PUBLIC_ enum ndr_err_code ndr_push_error(struct ndr_push *ndr,
 		return NDR_ERR_ALLOC;
 	}
 
-	DEBUG(1,("ndr_push_error(%u): %s\n", ndr_err, s));
+	D_WARNING("%s: ndr_push_error(%s): %s at %s\n",
+		  function,
+		  ndr_map_error2string(ndr_err),
+		  s,
+		  location);
 
 	free(s);
 
diff --git a/librpc/wscript_build b/librpc/wscript_build
index f5f8a344f64..2582a281139 100644
--- a/librpc/wscript_build
+++ b/librpc/wscript_build
@@ -620,9 +620,9 @@ bld.SAMBA_LIBRARY('ndr',
     public_deps='samba-errors talloc samba-util util_str_hex',
     public_headers='gen_ndr/misc.h gen_ndr/ndr_misc.h ndr/libndr.h:ndr.h',
     header_path= [('*gen_ndr*', 'gen_ndr')],
-    vnum='0.2.1',
+    vnum='1.0.0',
     abi_directory='ABI',
-    abi_match='ndr_* GUID_*',
+    abi_match='!ndr_table_* ndr_* GUID_* _ndr_pull_error _ndr_push_error',
     )
 
 bld.SAMBA_LIBRARY('dcerpc-binding',
diff --git a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
index 222a8b8c7b4..8759e46aedb 100644
--- a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
@@ -1920,7 +1920,7 @@ sub ParseUnionPushPrimitives($$$$)
 	}
 	if (! $have_default) {
 		$self->pidl("default:");
-		$self->pidl("\treturn ndr_push_error($ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u at \%s\", level, __location__);");
+		$self->pidl("\treturn ndr_push_error($ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u\", level);");
 	}
 	$self->deindent;
 	$self->pidl("}");
@@ -1956,7 +1956,7 @@ sub ParseUnionPushDeferred($$$$)
 	}
 	if (! $have_default) {
 		$self->pidl("default:");
-		$self->pidl("\treturn ndr_push_error($ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u at \%s\", level, __location__);");
+		$self->pidl("\treturn ndr_push_error($ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u\", level);");
 	}
 	$self->deindent;
 	$self->pidl("}");


-- 
Samba Shared Repository



More information about the samba-cvs mailing list