From 15c5f2acb8cdbbc5a4f824df9c8a2a2105e8b74f Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Wed, 13 Feb 2019 10:35:13 +0100 Subject: [PATCH 1/5] librpc:ndr: Implement ndr_zero_memory() BUG: https://bugzilla.samba.org/show_bug.cgi?id=13778 Signed-off-by: Andreas Schneider Reviewed-by: Stefan Metzmacher (cherry picked from commit 2a7086f1ac4ad91fb7cd958e9386abb996794ed1) --- librpc/ABI/ndr-0.2.0.sigs | 264 ++++++++++++++++++++++++++++++++++++++ librpc/ndr/libndr.h | 1 + librpc/ndr/util.c | 5 + librpc/wscript_build | 2 +- 4 files changed, 271 insertions(+), 1 deletion(-) create mode 100644 librpc/ABI/ndr-0.2.0.sigs diff --git a/librpc/ABI/ndr-0.2.0.sigs b/librpc/ABI/ndr-0.2.0.sigs new file mode 100644 index 00000000000..6346f2fb491 --- /dev/null +++ b/librpc/ABI/ndr-0.2.0.sigs @@ -0,0 +1,264 @@ +GUID_all_zero: bool (const struct GUID *) +GUID_buf_string: char *(const struct GUID *, struct GUID_txt_buf *) +GUID_compare: int (const struct GUID *, const struct GUID *) +GUID_equal: bool (const struct GUID *, const struct GUID *) +GUID_from_data_blob: NTSTATUS (const DATA_BLOB *, struct GUID *) +GUID_from_ndr_blob: NTSTATUS (const DATA_BLOB *, struct GUID *) +GUID_from_string: NTSTATUS (const char *, struct GUID *) +GUID_hexstring: char *(TALLOC_CTX *, const struct GUID *) +GUID_random: struct GUID (void) +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_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) +ndr_check_array_size: enum ndr_err_code (struct ndr_pull *, void *, uint32_t) +ndr_check_padding: void (struct ndr_pull *, size_t) +ndr_check_pipe_chunk_trailer: enum ndr_err_code (struct ndr_pull *, int, uint32_t) +ndr_check_string_terminator: enum ndr_err_code (struct ndr_pull *, uint32_t, uint32_t) +ndr_get_array_length: uint32_t (struct ndr_pull *, const void *) +ndr_get_array_size: uint32_t (struct ndr_pull *, const void *) +ndr_map_error2errno: int (enum ndr_err_code) +ndr_map_error2ntstatus: NTSTATUS (enum ndr_err_code) +ndr_map_error2string: const char *(enum ndr_err_code) +ndr_policy_handle_empty: bool (const struct policy_handle *) +ndr_policy_handle_equal: bool (const struct policy_handle *, const struct policy_handle *) +ndr_print_DATA_BLOB: void (struct ndr_print *, const char *, DATA_BLOB) +ndr_print_GUID: void (struct ndr_print *, const char *, const struct GUID *) +ndr_print_HRESULT: void (struct ndr_print *, const char *, HRESULT) +ndr_print_KRB5_EDATA_NTSTATUS: void (struct ndr_print *, const char *, const struct KRB5_EDATA_NTSTATUS *) +ndr_print_NTSTATUS: void (struct ndr_print *, const char *, NTSTATUS) +ndr_print_NTTIME: void (struct ndr_print *, const char *, NTTIME) +ndr_print_NTTIME_1sec: void (struct ndr_print *, const char *, NTTIME) +ndr_print_NTTIME_hyper: void (struct ndr_print *, const char *, NTTIME) +ndr_print_WERROR: void (struct ndr_print *, const char *, WERROR) +ndr_print_array_uint8: void (struct ndr_print *, const char *, const uint8_t *, uint32_t) +ndr_print_bad_level: void (struct ndr_print *, const char *, uint16_t) +ndr_print_bitmap_flag: void (struct ndr_print *, size_t, const char *, uint32_t, uint32_t) +ndr_print_bool: void (struct ndr_print *, const char *, const bool) +ndr_print_debug: void (ndr_print_fn_t, const char *, void *) +ndr_print_debug_helper: void (struct ndr_print *, const char *, ...) +ndr_print_debugc: void (int, ndr_print_fn_t, const char *, void *) +ndr_print_debugc_helper: void (struct ndr_print *, const char *, ...) +ndr_print_dlong: void (struct ndr_print *, const char *, int64_t) +ndr_print_double: void (struct ndr_print *, const char *, double) +ndr_print_enum: void (struct ndr_print *, const char *, const char *, const char *, uint32_t) +ndr_print_function_debug: void (ndr_print_function_t, const char *, int, void *) +ndr_print_function_string: char *(TALLOC_CTX *, ndr_print_function_t, const char *, int, void *) +ndr_print_get_switch_value: uint32_t (struct ndr_print *, const void *) +ndr_print_gid_t: void (struct ndr_print *, const char *, gid_t) +ndr_print_hyper: void (struct ndr_print *, const char *, uint64_t) +ndr_print_int16: void (struct ndr_print *, const char *, int16_t) +ndr_print_int32: void (struct ndr_print *, const char *, int32_t) +ndr_print_int3264: void (struct ndr_print *, const char *, int32_t) +ndr_print_int8: void (struct ndr_print *, const char *, int8_t) +ndr_print_ipv4address: void (struct ndr_print *, const char *, const char *) +ndr_print_ipv6address: void (struct ndr_print *, const char *, const char *) +ndr_print_ndr_syntax_id: void (struct ndr_print *, const char *, const struct ndr_syntax_id *) +ndr_print_netr_SamDatabaseID: void (struct ndr_print *, const char *, enum netr_SamDatabaseID) +ndr_print_netr_SchannelType: void (struct ndr_print *, const char *, enum netr_SchannelType) +ndr_print_null: void (struct ndr_print *) +ndr_print_pointer: void (struct ndr_print *, const char *, void *) +ndr_print_policy_handle: void (struct ndr_print *, const char *, const struct policy_handle *) +ndr_print_printf_helper: void (struct ndr_print *, const char *, ...) +ndr_print_ptr: void (struct ndr_print *, const char *, const void *) +ndr_print_set_switch_value: enum ndr_err_code (struct ndr_print *, const void *, uint32_t) +ndr_print_sockaddr_storage: void (struct ndr_print *, const char *, const struct sockaddr_storage *) +ndr_print_string: void (struct ndr_print *, const char *, const char *) +ndr_print_string_array: void (struct ndr_print *, const char *, const char **) +ndr_print_string_helper: void (struct ndr_print *, const char *, ...) +ndr_print_struct: void (struct ndr_print *, const char *, const char *) +ndr_print_struct_string: char *(TALLOC_CTX *, ndr_print_fn_t, const char *, void *) +ndr_print_svcctl_ServerType: void (struct ndr_print *, const char *, uint32_t) +ndr_print_time_t: void (struct ndr_print *, const char *, time_t) +ndr_print_timespec: void (struct ndr_print *, const char *, const struct timespec *) +ndr_print_timeval: void (struct ndr_print *, const char *, const struct timeval *) +ndr_print_udlong: void (struct ndr_print *, const char *, uint64_t) +ndr_print_udlongr: void (struct ndr_print *, const char *, uint64_t) +ndr_print_uid_t: void (struct ndr_print *, const char *, uid_t) +ndr_print_uint16: void (struct ndr_print *, const char *, uint16_t) +ndr_print_uint32: void (struct ndr_print *, const char *, uint32_t) +ndr_print_uint3264: void (struct ndr_print *, const char *, uint32_t) +ndr_print_uint8: void (struct ndr_print *, const char *, uint8_t) +ndr_print_union: void (struct ndr_print *, const char *, int, const char *) +ndr_print_union_debug: void (ndr_print_fn_t, const char *, uint32_t, void *) +ndr_print_union_string: char *(TALLOC_CTX *, ndr_print_fn_t, const char *, uint32_t, void *) +ndr_print_winreg_Data: void (struct ndr_print *, const char *, const union winreg_Data *) +ndr_print_winreg_Data_GPO: void (struct ndr_print *, const char *, const union winreg_Data_GPO *) +ndr_print_winreg_Type: void (struct ndr_print *, const char *, enum winreg_Type) +ndr_pull_DATA_BLOB: enum ndr_err_code (struct ndr_pull *, int, DATA_BLOB *) +ndr_pull_GUID: enum ndr_err_code (struct ndr_pull *, int, struct GUID *) +ndr_pull_HRESULT: enum ndr_err_code (struct ndr_pull *, int, HRESULT *) +ndr_pull_KRB5_EDATA_NTSTATUS: enum ndr_err_code (struct ndr_pull *, int, struct KRB5_EDATA_NTSTATUS *) +ndr_pull_NTSTATUS: enum ndr_err_code (struct ndr_pull *, int, NTSTATUS *) +ndr_pull_NTTIME: enum ndr_err_code (struct ndr_pull *, int, NTTIME *) +ndr_pull_NTTIME_1sec: enum ndr_err_code (struct ndr_pull *, int, NTTIME *) +ndr_pull_NTTIME_hyper: enum ndr_err_code (struct ndr_pull *, int, NTTIME *) +ndr_pull_WERROR: enum ndr_err_code (struct ndr_pull *, int, WERROR *) +ndr_pull_advance: enum ndr_err_code (struct ndr_pull *, uint32_t) +ndr_pull_align: enum ndr_err_code (struct ndr_pull *, size_t) +ndr_pull_append: enum ndr_err_code (struct ndr_pull *, DATA_BLOB *) +ndr_pull_array_length: enum ndr_err_code (struct ndr_pull *, const void *) +ndr_pull_array_size: enum ndr_err_code (struct ndr_pull *, const void *) +ndr_pull_array_uint8: enum ndr_err_code (struct ndr_pull *, int, uint8_t *, uint32_t) +ndr_pull_bytes: enum ndr_err_code (struct ndr_pull *, uint8_t *, uint32_t) +ndr_pull_charset: enum ndr_err_code (struct ndr_pull *, int, const char **, uint32_t, uint8_t, charset_t) +ndr_pull_charset_to_null: enum ndr_err_code (struct ndr_pull *, int, const char **, uint32_t, uint8_t, charset_t) +ndr_pull_dlong: enum ndr_err_code (struct ndr_pull *, int, int64_t *) +ndr_pull_double: enum ndr_err_code (struct ndr_pull *, int, double *) +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 *) +ndr_pull_gid_t: enum ndr_err_code (struct ndr_pull *, int, gid_t *) +ndr_pull_hyper: enum ndr_err_code (struct ndr_pull *, int, uint64_t *) +ndr_pull_init_blob: struct ndr_pull *(const DATA_BLOB *, TALLOC_CTX *) +ndr_pull_int16: enum ndr_err_code (struct ndr_pull *, int, int16_t *) +ndr_pull_int32: enum ndr_err_code (struct ndr_pull *, int, int32_t *) +ndr_pull_int8: enum ndr_err_code (struct ndr_pull *, int, int8_t *) +ndr_pull_ipv4address: enum ndr_err_code (struct ndr_pull *, int, const char **) +ndr_pull_ipv6address: enum ndr_err_code (struct ndr_pull *, int, const char **) +ndr_pull_ndr_syntax_id: enum ndr_err_code (struct ndr_pull *, int, struct ndr_syntax_id *) +ndr_pull_netr_SamDatabaseID: enum ndr_err_code (struct ndr_pull *, int, enum netr_SamDatabaseID *) +ndr_pull_netr_SchannelType: enum ndr_err_code (struct ndr_pull *, int, enum netr_SchannelType *) +ndr_pull_pointer: enum ndr_err_code (struct ndr_pull *, int, void **) +ndr_pull_policy_handle: enum ndr_err_code (struct ndr_pull *, int, struct policy_handle *) +ndr_pull_pop: enum ndr_err_code (struct ndr_pull *) +ndr_pull_ref_ptr: enum ndr_err_code (struct ndr_pull *, uint32_t *) +ndr_pull_relative_ptr1: enum ndr_err_code (struct ndr_pull *, const void *, uint32_t) +ndr_pull_relative_ptr2: enum ndr_err_code (struct ndr_pull *, const void *) +ndr_pull_relative_ptr_short: enum ndr_err_code (struct ndr_pull *, uint16_t *) +ndr_pull_restore_relative_base_offset: void (struct ndr_pull *, uint32_t) +ndr_pull_set_switch_value: enum ndr_err_code (struct ndr_pull *, const void *, uint32_t) +ndr_pull_setup_relative_base_offset1: enum ndr_err_code (struct ndr_pull *, const void *, uint32_t) +ndr_pull_setup_relative_base_offset2: enum ndr_err_code (struct ndr_pull *, const void *) +ndr_pull_steal_switch_value: uint32_t (struct ndr_pull *, const void *) +ndr_pull_string: enum ndr_err_code (struct ndr_pull *, int, const char **) +ndr_pull_string_array: enum ndr_err_code (struct ndr_pull *, int, const char ***) +ndr_pull_struct_blob: enum ndr_err_code (const DATA_BLOB *, TALLOC_CTX *, void *, ndr_pull_flags_fn_t) +ndr_pull_struct_blob_all: enum ndr_err_code (const DATA_BLOB *, TALLOC_CTX *, void *, ndr_pull_flags_fn_t) +ndr_pull_struct_blob_all_noalloc: enum ndr_err_code (const DATA_BLOB *, void *, ndr_pull_flags_fn_t) +ndr_pull_subcontext_end: enum ndr_err_code (struct ndr_pull *, struct ndr_pull *, size_t, ssize_t) +ndr_pull_subcontext_start: enum ndr_err_code (struct ndr_pull *, struct ndr_pull **, size_t, ssize_t) +ndr_pull_svcctl_ServerType: enum ndr_err_code (struct ndr_pull *, int, uint32_t *) +ndr_pull_time_t: enum ndr_err_code (struct ndr_pull *, int, time_t *) +ndr_pull_timespec: enum ndr_err_code (struct ndr_pull *, int, struct timespec *) +ndr_pull_timeval: enum ndr_err_code (struct ndr_pull *, int, struct timeval *) +ndr_pull_trailer_align: enum ndr_err_code (struct ndr_pull *, size_t) +ndr_pull_udlong: enum ndr_err_code (struct ndr_pull *, int, uint64_t *) +ndr_pull_udlongr: enum ndr_err_code (struct ndr_pull *, int, uint64_t *) +ndr_pull_uid_t: enum ndr_err_code (struct ndr_pull *, int, uid_t *) +ndr_pull_uint16: enum ndr_err_code (struct ndr_pull *, int, uint16_t *) +ndr_pull_uint1632: enum ndr_err_code (struct ndr_pull *, int, uint16_t *) +ndr_pull_uint32: enum ndr_err_code (struct ndr_pull *, int, uint32_t *) +ndr_pull_uint3264: enum ndr_err_code (struct ndr_pull *, int, uint32_t *) +ndr_pull_uint8: enum ndr_err_code (struct ndr_pull *, int, uint8_t *) +ndr_pull_union_align: enum ndr_err_code (struct ndr_pull *, size_t) +ndr_pull_union_blob: enum ndr_err_code (const DATA_BLOB *, TALLOC_CTX *, void *, uint32_t, ndr_pull_flags_fn_t) +ndr_pull_union_blob_all: enum ndr_err_code (const DATA_BLOB *, TALLOC_CTX *, void *, uint32_t, ndr_pull_flags_fn_t) +ndr_pull_winreg_Data: enum ndr_err_code (struct ndr_pull *, int, union winreg_Data *) +ndr_pull_winreg_Data_GPO: enum ndr_err_code (struct ndr_pull *, int, union winreg_Data_GPO *) +ndr_pull_winreg_Type: enum ndr_err_code (struct ndr_pull *, int, enum winreg_Type *) +ndr_push_DATA_BLOB: enum ndr_err_code (struct ndr_push *, int, DATA_BLOB) +ndr_push_GUID: enum ndr_err_code (struct ndr_push *, int, const struct GUID *) +ndr_push_HRESULT: enum ndr_err_code (struct ndr_push *, int, HRESULT) +ndr_push_KRB5_EDATA_NTSTATUS: enum ndr_err_code (struct ndr_push *, int, const struct KRB5_EDATA_NTSTATUS *) +ndr_push_NTSTATUS: enum ndr_err_code (struct ndr_push *, int, NTSTATUS) +ndr_push_NTTIME: enum ndr_err_code (struct ndr_push *, int, NTTIME) +ndr_push_NTTIME_1sec: enum ndr_err_code (struct ndr_push *, int, NTTIME) +ndr_push_NTTIME_hyper: enum ndr_err_code (struct ndr_push *, int, NTTIME) +ndr_push_WERROR: enum ndr_err_code (struct ndr_push *, int, WERROR) +ndr_push_align: enum ndr_err_code (struct ndr_push *, size_t) +ndr_push_array_uint8: enum ndr_err_code (struct ndr_push *, int, const uint8_t *, uint32_t) +ndr_push_blob: DATA_BLOB (struct ndr_push *) +ndr_push_bytes: enum ndr_err_code (struct ndr_push *, const uint8_t *, uint32_t) +ndr_push_charset: enum ndr_err_code (struct ndr_push *, int, const char *, uint32_t, uint8_t, charset_t) +ndr_push_charset_to_null: enum ndr_err_code (struct ndr_push *, int, const char *, uint32_t, uint8_t, charset_t) +ndr_push_dlong: enum ndr_err_code (struct ndr_push *, int, int64_t) +ndr_push_double: enum ndr_err_code (struct ndr_push *, int, double) +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 *) +ndr_push_get_switch_value: uint32_t (struct ndr_push *, const void *) +ndr_push_gid_t: enum ndr_err_code (struct ndr_push *, int, gid_t) +ndr_push_hyper: enum ndr_err_code (struct ndr_push *, int, uint64_t) +ndr_push_init_ctx: struct ndr_push *(TALLOC_CTX *) +ndr_push_int16: enum ndr_err_code (struct ndr_push *, int, int16_t) +ndr_push_int32: enum ndr_err_code (struct ndr_push *, int, int32_t) +ndr_push_int8: enum ndr_err_code (struct ndr_push *, int, int8_t) +ndr_push_ipv4address: enum ndr_err_code (struct ndr_push *, int, const char *) +ndr_push_ipv6address: enum ndr_err_code (struct ndr_push *, int, const char *) +ndr_push_ndr_syntax_id: enum ndr_err_code (struct ndr_push *, int, const struct ndr_syntax_id *) +ndr_push_netr_SamDatabaseID: enum ndr_err_code (struct ndr_push *, int, enum netr_SamDatabaseID) +ndr_push_netr_SchannelType: enum ndr_err_code (struct ndr_push *, int, enum netr_SchannelType) +ndr_push_pipe_chunk_trailer: enum ndr_err_code (struct ndr_push *, int, uint32_t) +ndr_push_pointer: enum ndr_err_code (struct ndr_push *, int, void *) +ndr_push_policy_handle: enum ndr_err_code (struct ndr_push *, int, const struct policy_handle *) +ndr_push_ref_ptr: enum ndr_err_code (struct ndr_push *) +ndr_push_relative_ptr1: enum ndr_err_code (struct ndr_push *, const void *) +ndr_push_relative_ptr2_end: enum ndr_err_code (struct ndr_push *, const void *) +ndr_push_relative_ptr2_start: enum ndr_err_code (struct ndr_push *, const void *) +ndr_push_restore_relative_base_offset: void (struct ndr_push *, uint32_t) +ndr_push_set_switch_value: enum ndr_err_code (struct ndr_push *, const void *, uint32_t) +ndr_push_setup_relative_base_offset1: enum ndr_err_code (struct ndr_push *, const void *, uint32_t) +ndr_push_setup_relative_base_offset2: enum ndr_err_code (struct ndr_push *, const void *) +ndr_push_short_relative_ptr1: enum ndr_err_code (struct ndr_push *, const void *) +ndr_push_short_relative_ptr2: enum ndr_err_code (struct ndr_push *, const void *) +ndr_push_string: enum ndr_err_code (struct ndr_push *, int, const char *) +ndr_push_string_array: enum ndr_err_code (struct ndr_push *, int, const char **) +ndr_push_struct_blob: enum ndr_err_code (DATA_BLOB *, TALLOC_CTX *, const void *, ndr_push_flags_fn_t) +ndr_push_struct_into_fixed_blob: enum ndr_err_code (DATA_BLOB *, const void *, ndr_push_flags_fn_t) +ndr_push_subcontext_end: enum ndr_err_code (struct ndr_push *, struct ndr_push *, size_t, ssize_t) +ndr_push_subcontext_start: enum ndr_err_code (struct ndr_push *, struct ndr_push **, size_t, ssize_t) +ndr_push_svcctl_ServerType: enum ndr_err_code (struct ndr_push *, int, uint32_t) +ndr_push_time_t: enum ndr_err_code (struct ndr_push *, int, time_t) +ndr_push_timespec: enum ndr_err_code (struct ndr_push *, int, const struct timespec *) +ndr_push_timeval: enum ndr_err_code (struct ndr_push *, int, const struct timeval *) +ndr_push_trailer_align: enum ndr_err_code (struct ndr_push *, size_t) +ndr_push_udlong: enum ndr_err_code (struct ndr_push *, int, uint64_t) +ndr_push_udlongr: enum ndr_err_code (struct ndr_push *, int, uint64_t) +ndr_push_uid_t: enum ndr_err_code (struct ndr_push *, int, uid_t) +ndr_push_uint16: enum ndr_err_code (struct ndr_push *, int, uint16_t) +ndr_push_uint1632: enum ndr_err_code (struct ndr_push *, int, uint16_t) +ndr_push_uint32: enum ndr_err_code (struct ndr_push *, int, uint32_t) +ndr_push_uint3264: enum ndr_err_code (struct ndr_push *, int, uint32_t) +ndr_push_uint8: enum ndr_err_code (struct ndr_push *, int, uint8_t) +ndr_push_union_align: enum ndr_err_code (struct ndr_push *, size_t) +ndr_push_union_blob: enum ndr_err_code (DATA_BLOB *, TALLOC_CTX *, void *, uint32_t, ndr_push_flags_fn_t) +ndr_push_unique_ptr: enum ndr_err_code (struct ndr_push *, const void *) +ndr_push_winreg_Data: enum ndr_err_code (struct ndr_push *, int, const union winreg_Data *) +ndr_push_winreg_Data_GPO: enum ndr_err_code (struct ndr_push *, int, const union winreg_Data_GPO *) +ndr_push_winreg_Type: enum ndr_err_code (struct ndr_push *, int, enum winreg_Type) +ndr_push_zero: enum ndr_err_code (struct ndr_push *, uint32_t) +ndr_set_flags: void (uint32_t *, uint32_t) +ndr_size_DATA_BLOB: uint32_t (int, const DATA_BLOB *, int) +ndr_size_GUID: size_t (const struct GUID *, int) +ndr_size_string: uint32_t (int, const char * const *, int) +ndr_size_string_array: size_t (const char **, uint32_t, int) +ndr_size_struct: size_t (const void *, int, ndr_push_flags_fn_t) +ndr_size_union: size_t (const void *, int, uint32_t, ndr_push_flags_fn_t) +ndr_size_winreg_Data_GPO: size_t (const union winreg_Data_GPO *, uint32_t, int) +ndr_string_array_size: size_t (struct ndr_push *, const char *) +ndr_string_length: uint32_t (const void *, uint32_t) +ndr_syntax_id_equal: bool (const struct ndr_syntax_id *, const struct ndr_syntax_id *) +ndr_syntax_id_from_string: bool (const char *, struct ndr_syntax_id *) +ndr_syntax_id_null: uuid = {time_low = 0, time_mid = 0, time_hi_and_version = 0, clock_seq = "\000", node = "\000\000\000\000\000"}, if_version = 0 +ndr_syntax_id_to_string: char *(TALLOC_CTX *, const struct ndr_syntax_id *) +ndr_token_peek: uint32_t (struct ndr_token_list *, const void *) +ndr_token_retrieve: enum ndr_err_code (struct ndr_token_list *, const void *, uint32_t *) +ndr_token_retrieve_cmp_fn: enum ndr_err_code (struct ndr_token_list *, const void *, uint32_t *, comparison_fn_t, bool) +ndr_token_store: enum ndr_err_code (TALLOC_CTX *, struct ndr_token_list *, const void *, uint32_t) +ndr_transfer_syntax_ndr: uuid = {time_low = 2324192516, time_mid = 7403, time_hi_and_version = 4553, clock_seq = "\237\350", node = "\b\000+\020H`"}, if_version = 2 +ndr_transfer_syntax_ndr64: uuid = {time_low = 1903232307, time_mid = 48826, time_hi_and_version = 18743, clock_seq = "\203\031", node = "\265\333\357\234\314\066"}, if_version = 1 +ndr_zero_memory: void (void *, size_t) diff --git a/librpc/ndr/libndr.h b/librpc/ndr/libndr.h index c31496fe1dc..1f0f3c227cf 100644 --- a/librpc/ndr/libndr.h +++ b/librpc/ndr/libndr.h @@ -493,6 +493,7 @@ void ndr_print_dom_sid0(struct ndr_print *ndr, const char *name, const struct do size_t ndr_size_dom_sid0(const struct dom_sid *sid, int flags); void ndr_print_GUID(struct ndr_print *ndr, const char *name, const struct GUID *guid); void ndr_print_sockaddr_storage(struct ndr_print *ndr, const char *name, const struct sockaddr_storage *ss); +void ndr_zero_memory(void *ptr, size_t len); bool ndr_syntax_id_equal(const struct ndr_syntax_id *i1, const struct ndr_syntax_id *i2); char *ndr_syntax_id_to_string(TALLOC_CTX *mem_ctx, const struct ndr_syntax_id *id); bool ndr_syntax_id_from_string(const char *s, struct ndr_syntax_id *id); diff --git a/librpc/ndr/util.c b/librpc/ndr/util.c index b2df28dde09..0eb7eba9e5e 100644 --- a/librpc/ndr/util.c +++ b/librpc/ndr/util.c @@ -29,3 +29,8 @@ _PUBLIC_ void ndr_print_sockaddr_storage(struct ndr_print *ndr, const char *name char addr[INET6_ADDRSTRLEN]; ndr->print(ndr, "%-25s: %s", name, print_sockaddr(addr, sizeof(addr), ss)); } + +_PUBLIC_ void ndr_zero_memory(void *ptr, size_t len) +{ + memset_s(ptr, len, 0, len); +} diff --git a/librpc/wscript_build b/librpc/wscript_build index 9669dfce2bf..8e113c422b2 100644 --- a/librpc/wscript_build +++ b/librpc/wscript_build @@ -725,7 +725,7 @@ 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.1.2', + vnum='0.2.0', abi_directory='ABI', abi_match='ndr_* GUID_*', ) -- 2.20.1 From 3bebbf9a0db492d95c19d88478dc0ab62fcff5c6 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Wed, 13 Feb 2019 10:38:02 +0100 Subject: [PATCH 2/5] librpc:ndr: Add NDR_ZERO_STRUCT(P) macros BUG: https://bugzilla.samba.org/show_bug.cgi?id=13778 Signed-off-by: Andreas Schneider Reviewed-by: Stefan Metzmacher (cherry picked from commit 666802a3db3115ca09f3ffed58c8e4a8cabd65de) --- librpc/ndr/libndr.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/librpc/ndr/libndr.h b/librpc/ndr/libndr.h index 1f0f3c227cf..9c403319b6e 100644 --- a/librpc/ndr/libndr.h +++ b/librpc/ndr/libndr.h @@ -411,6 +411,13 @@ enum ndr_compression_alg { if (unlikely(!(s))) return ndr_push_error(ndr, NDR_ERR_ALLOC, "push alloc %s failed: %s\n", # s, __location__); \ } while (0) +#define NDR_ZERO_STRUCT(x) ndr_zero_memory(&(x), sizeof(x)) +#define NDR_ZERO_STRUCTP(x) do { \ + if ((x) != NULL) { \ + ndr_zero_memory((x), sizeof(*(x))); \ + } \ +} while(0) + /* these are used when generic fn pointers are needed for ndr push/pull fns */ typedef enum ndr_err_code (*ndr_push_flags_fn_t)(struct ndr_push *, int ndr_flags, const void *); typedef enum ndr_err_code (*ndr_pull_flags_fn_t)(struct ndr_pull *, int ndr_flags, void *); -- 2.20.1 From 55f4a351184ab2fbc1b5d14b0290f0f45b748795 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Wed, 13 Feb 2019 10:41:19 +0100 Subject: [PATCH 3/5] pidl: Use NDR_ZERO_STRUCT(P) macros BUG: https://bugzilla.samba.org/show_bug.cgi?id=13778 Signed-off-by: Andreas Schneider Reviewed-by: Stefan Metzmacher (cherry picked from commit 532ce0d20a8016c1270ea689de627da8aa4abfdd) --- pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm | 2 +- pidl/lib/Parse/Pidl/Samba4/COM/Proxy.pm | 2 +- pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm | 6 +++--- pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm b/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm index c87d17a5a78..fa7303b8543 100644 --- a/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm +++ b/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm @@ -103,7 +103,7 @@ sub CallWithStruct($$$$$$) if (grep(/out/, @{$_->{DIRECTION}})) { $hasout = 1; } } - pidl "ZERO_STRUCT(r->out);" if ($hasout); + pidl "NDR_ZERO_STRUCT(r->out);" if ($hasout); foreach (@{$fn->{ELEMENTS}}) { my @dir = @{$_->{DIRECTION}}; diff --git a/pidl/lib/Parse/Pidl/Samba4/COM/Proxy.pm b/pidl/lib/Parse/Pidl/Samba4/COM/Proxy.pm index 35e6e3f0d19..de050e8f8c6 100644 --- a/pidl/lib/Parse/Pidl/Samba4/COM/Proxy.pm +++ b/pidl/lib/Parse/Pidl/Samba4/COM/Proxy.pm @@ -101,7 +101,7 @@ static $tn dcom_proxy_$interface->{NAME}_$name(struct $interface->{NAME} *d, TAL return status; } - ZERO_STRUCT(r.in.ORPCthis); + NDR_ZERO_STRUCT(r.in.ORPCthis); r.in.ORPCthis.version.MajorVersion = COM_MAJOR_VERSION; r.in.ORPCthis.version.MinorVersion = COM_MINOR_VERSION; "; diff --git a/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm index 040cd5a4bd3..734e86dd183 100644 --- a/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm +++ b/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm @@ -496,7 +496,7 @@ sub ParseFunction_Send($$$$) if (defined($fn->{RETURN_TYPE})) { $self->pidl("/* Result */"); - $self->pidl("ZERO_STRUCT(state->orig.out.result);"); + $self->pidl("NDR_ZERO_STRUCT(state->orig.out.result);"); $self->pidl(""); } @@ -585,7 +585,7 @@ sub ParseFunction_Done($$$$) } $self->pidl("/* Reset temporary structure */"); - $self->pidl("ZERO_STRUCT(state->tmp);"); + $self->pidl("NDR_ZERO_STRUCT(state->tmp);"); $self->pidl(""); $self->pidl("tevent_req_done(req);"); @@ -698,7 +698,7 @@ sub ParseFunction_Sync($$$$) if (defined($fn->{RETURN_TYPE})) { $self->pidl("/* Result */"); - $self->pidl("ZERO_STRUCT(r.out.result);"); + $self->pidl("NDR_ZERO_STRUCT(r.out.result);"); $self->pidl(""); } diff --git a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm index eae58a9a432..432e52f89c4 100644 --- a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm +++ b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm @@ -1134,7 +1134,7 @@ sub ParseElementPullLevel if (has_property($e, "skip") or has_property($e, "skip_noinit")) { $self->pidl("/* [skip] '$var_name' */"); if (not has_property($e, "skip_noinit")) { - $self->pidl("ZERO_STRUCT($var_name);"); + $self->pidl("NDR_ZERO_STRUCT($var_name);"); } return; } @@ -2551,7 +2551,7 @@ sub ParseFunctionPull($$) # out to be too tricky (tridge) foreach my $e (@{$fn->{ELEMENTS}}) { next unless grep(/out/, @{$e->{DIRECTION}}); - $self->pidl("ZERO_STRUCT(r->out);"); + $self->pidl("NDR_ZERO_STRUCT(r->out);"); $self->pidl(""); last; } @@ -2600,7 +2600,7 @@ sub ParseFunctionPull($$) if (grep(/in/, @{$e->{DIRECTION}})) { $self->pidl("*r->out.$e->{NAME} = *r->in.$e->{NAME};"); } else { - $self->pidl("ZERO_STRUCTP(r->out.$e->{NAME});"); + $self->pidl("NDR_ZERO_STRUCTP(r->out.$e->{NAME});"); } } } -- 2.20.1 From 054018f2a06fcebe5d2e40d7b065c63aac44c9b6 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Wed, 6 Feb 2019 16:05:48 +0100 Subject: [PATCH 4/5] lib:util: Move discard_const(_p) to own header for libndr.h BUG: https://bugzilla.samba.org/show_bug.cgi?id=13778 Signed-off-by: Andreas Schneider Reviewed-by: Guenther Deschner Reviewed-by: Stefan Metzmacher (cherry picked from commit 96df6878ed521b7e744d703abb32a585500d3b94) --- lib/util/discard.h | 51 +++++++++++++++++++++++++++++++++ lib/util/memory.h | 27 ----------------- lib/util/samba_util.h | 1 + lib/util/wscript_build | 2 +- librpc/ndr/libndr.h | 2 +- source3/libsmb/samlogon_cache.c | 1 + 6 files changed, 55 insertions(+), 29 deletions(-) create mode 100644 lib/util/discard.h diff --git a/lib/util/discard.h b/lib/util/discard.h new file mode 100644 index 00000000000..d2b74ac989c --- /dev/null +++ b/lib/util/discard.h @@ -0,0 +1,51 @@ +/* + Unix SMB/CIFS implementation. + Samba utility functions + Copyright (C) Andrew Tridgell 1992-1999 + Copyright (C) Jelmer Vernooij 2008 + + 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 3 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, see . +*/ + +#ifndef _SAMBA_DISCARD_H_ +#define _SAMBA_DISCARD_H_ + +/** + this is a warning hack. The idea is to use this everywhere that we + get the "discarding const" warning from gcc. That doesn't actually + fix the problem of course, but it means that when we do get to + cleaning them up we can do it by searching the code for + discard_const. + + It also means that other error types aren't as swamped by the noise + of hundreds of const warnings, so we are more likely to notice when + we get new errors. + + Please only add more uses of this macro when you find it + _really_ hard to fix const warnings. Our aim is to eventually use + this function in only a very few places. + + Also, please call this via the discard_const_p() macro interface, as that + makes the return type safe. +*/ +#ifndef discard_const +#define discard_const(ptr) ((void *)((uintptr_t)(ptr))) +#endif + +/** Type-safe version of discard_const */ +#ifndef discard_const_p +#define discard_const_p(type, ptr) ((type *)discard_const(ptr)) +#endif + +#endif /* _SAMBA_DISCARD_H_ */ diff --git a/lib/util/memory.h b/lib/util/memory.h index 3278f6b3c21..0e151cc5f66 100644 --- a/lib/util/memory.h +++ b/lib/util/memory.h @@ -94,31 +94,4 @@ #define PTR_DIFF(p1,p2) ((ptrdiff_t)(((const char *)(p1)) - (const char *)(p2))) #endif -/** - this is a warning hack. The idea is to use this everywhere that we - get the "discarding const" warning from gcc. That doesn't actually - fix the problem of course, but it means that when we do get to - cleaning them up we can do it by searching the code for - discard_const. - - It also means that other error types aren't as swamped by the noise - of hundreds of const warnings, so we are more likely to notice when - we get new errors. - - Please only add more uses of this macro when you find it - _really_ hard to fix const warnings. Our aim is to eventually use - this function in only a very few places. - - Also, please call this via the discard_const_p() macro interface, as that - makes the return type safe. -*/ -#ifndef discard_const -#define discard_const(ptr) ((void *)((uintptr_t)(ptr))) -#endif - -/** Type-safe version of discard_const */ -#ifndef discard_const_p -#define discard_const_p(type, ptr) ((type *)discard_const(ptr)) -#endif - #endif /* _SAMBA_MEMORY_H_ */ diff --git a/lib/util/samba_util.h b/lib/util/samba_util.h index 7b96a595d43..11c95b5bfe3 100644 --- a/lib/util/samba_util.h +++ b/lib/util/samba_util.h @@ -54,6 +54,7 @@ extern const char *panic_action; #endif #include "lib/util/memory.h" +#include "lib/util/discard.h" #include "fault.h" diff --git a/lib/util/wscript_build b/lib/util/wscript_build index 8fc402062fb..9c9652b26cd 100644 --- a/lib/util/wscript_build +++ b/lib/util/wscript_build @@ -126,7 +126,7 @@ else: tevent_debug.c memcache.c unix_match.c tfork.c''', deps='samba-util-core DYNCONFIG close-low-fd tiniparser genrand util_str_hex', public_deps='talloc tevent execinfo pthread LIBCRYPTO charset util_setid', - public_headers='debug.h attr.h byteorder.h data_blob.h memory.h safe_string.h time.h talloc_stack.h string_wrappers.h idtree.h idtree_random.h blocking.h signal.h substitute.h fault.h genrand.h tfork.h', + public_headers='debug.h attr.h byteorder.h data_blob.h discard.h memory.h safe_string.h time.h talloc_stack.h string_wrappers.h idtree.h idtree_random.h blocking.h signal.h substitute.h fault.h genrand.h tfork.h', header_path= [ ('dlinklist.h samba_util.h', '.'), ('*', 'util') ], local_include=False, vnum='0.0.1', diff --git a/librpc/ndr/libndr.h b/librpc/ndr/libndr.h index 9c403319b6e..8a15fccfe09 100644 --- a/librpc/ndr/libndr.h +++ b/librpc/ndr/libndr.h @@ -26,7 +26,7 @@ #define __LIBNDR_H__ #include -#include "../lib/util/memory.h" /* for discard_const */ +#include "../lib/util/discard.h" /* for discard_const */ #include "../lib/util/byteorder.h" #include "../lib/util/data_blob.h" #include "../lib/util/time.h" diff --git a/source3/libsmb/samlogon_cache.c b/source3/libsmb/samlogon_cache.c index 494eb10a6a8..a9ddaab1a41 100644 --- a/source3/libsmb/samlogon_cache.c +++ b/source3/libsmb/samlogon_cache.c @@ -27,6 +27,7 @@ #include "system/time.h" #include "lib/util/debug.h" #include "lib/util/talloc_stack.h" +#include "lib/util/memory.h" /* for SAFE_FREE() */ #include "source3/lib/util_path.h" #include "librpc/gen_ndr/ndr_krb5pac.h" #include "../libcli/security/security.h" -- 2.20.1 From 31875c1f889073a962a1da0fe2e22107a403016f Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Wed, 13 Feb 2019 10:44:45 +0100 Subject: [PATCH 5/5] waf: Do not install internal header We should not install header files without an public API: - memory.h - safe_strings.h - talloc_stack.h BUG: https://bugzilla.samba.org/show_bug.cgi?id=13778 Signed-off-by: Andreas Schneider Reviewed-by: Stefan Metzmacher (cherry picked from commit 6d232f3f7c64f9b01439326e0e9b6d9df9a0bcbb) --- lib/util/wscript_build | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/util/wscript_build b/lib/util/wscript_build index 9c9652b26cd..e3a004fa3c6 100644 --- a/lib/util/wscript_build +++ b/lib/util/wscript_build @@ -126,7 +126,23 @@ else: tevent_debug.c memcache.c unix_match.c tfork.c''', deps='samba-util-core DYNCONFIG close-low-fd tiniparser genrand util_str_hex', public_deps='talloc tevent execinfo pthread LIBCRYPTO charset util_setid', - public_headers='debug.h attr.h byteorder.h data_blob.h discard.h memory.h safe_string.h time.h talloc_stack.h string_wrappers.h idtree.h idtree_random.h blocking.h signal.h substitute.h fault.h genrand.h tfork.h', + public_headers=''' + attr.h + byteorder.h + data_blob.h + debug.h + discard.h + time.h + string_wrappers.h + idtree.h + idtree_random.h + blocking.h + signal.h + substitute.h + fault.h + genrand.h + tfork.h + ''', header_path= [ ('dlinklist.h samba_util.h', '.'), ('*', 'util') ], local_include=False, vnum='0.0.1', -- 2.20.1