The branch, master has been updated
via 93d21dc7e96 third_party: Update cmocka to version 1.1.8
via 0ff580d4650 s4:kdc: Fix cmocka.h include
via 50604bc027c Add missing include needed for cmocka.h
from 0e73781bf84 ctdb-scripts: Avoid failing updateip when IP is not
assigned
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 93d21dc7e961f1eaa8aa0075c53b2b1134955780
Author: Andreas Schneider <[email protected]>
Date: Wed Oct 15 11:39:42 2025 +0200
third_party: Update cmocka to version 1.1.8
Signed-off-by: Andreas Schneider <[email protected]>
Reviewed-by: Anoop C S <[email protected]>
Autobuild-User(master): Anoop C S <[email protected]>
Autobuild-Date(master): Fri Oct 17 12:16:23 UTC 2025 on atb-devel-224
commit 0ff580d46507bdeb19f862c33137209996f0fc65
Author: Andreas Schneider <[email protected]>
Date: Fri Oct 17 09:10:29 2025 +0200
s4:kdc: Fix cmocka.h include
Signed-off-by: Andreas Schneider <[email protected]>
Reviewed-by: Anoop C S <[email protected]>
commit 50604bc027c3d053cafd803ff515e6da881e79a5
Author: Andreas Schneider <[email protected]>
Date: Thu Aug 7 10:36:51 2025 +0200
Add missing include needed for cmocka.h
This will be required in future.
Signed-off-by: Andreas Schneider <[email protected]>
Reviewed-by: Anoop C S <[email protected]>
-----------------------------------------------------------------------
Summary of changes:
buildtools/wafsamba/samba_third_party.py | 2 +-
lib/audit_logging/tests/audit_logging_error_test.c | 1 +
lib/audit_logging/tests/audit_logging_test.c | 1 +
lib/compression/tests/test_lzx_huffman.c | 1 +
lib/compression/tests/test_lzxpress_plain.c | 1 +
lib/ldb/tests/test_ldb_comparison_fold.c | 1 +
lib/pthreadpool/tests_cmocka.c | 1 +
lib/util/tests/test_stable_sort.c | 1 +
libcli/drsuapi/tests/test_repl_decrypt.c | 1 +
libcli/ldap/tests/ldap_message_test.c | 1 +
libcli/security/tests/test_run_conditional_ace.c | 1 +
libcli/security/tests/test_sddl_conditional_ace.c | 1 +
source4/auth/tests/heimdal_unwrap_des.c | 1 +
.../dsdb/samdb/ldb_modules/tests/test_audit_log.c | 1 +
.../ldb_modules/tests/test_audit_log_errors.c | 1 +
.../dsdb/samdb/ldb_modules/tests/test_audit_util.c | 1 +
.../ldb_modules/tests/test_encrypted_secrets.c | 1 +
.../samdb/ldb_modules/tests/test_group_audit.c | 1 +
.../ldb_modules/tests/test_group_audit_errors.c | 1 +
.../ldb_modules/tests/test_unique_object_sids.c | 1 +
source4/kdc/tests/db-glue-test.c | 3 +-
source4/kdc/tests/sdb_to_hdb_test.c | 3 +-
.../tests/rpc_dns_server_dnsutils_test.c | 1 +
testsuite/unittests/test_krb5_samba.c | 1 +
testsuite/unittests/test_lib_util_modules.c | 1 +
third_party/cmocka/cmocka.c | 426 ++++++++++++++++-----
third_party/cmocka/cmocka.h | 203 ++++++++--
third_party/cmocka/cmocka_private.h | 2 +
third_party/cmocka/wscript | 6 +-
29 files changed, 547 insertions(+), 120 deletions(-)
Changeset truncated at 500 lines:
diff --git a/buildtools/wafsamba/samba_third_party.py
b/buildtools/wafsamba/samba_third_party.py
index 8f0c56dec79..425c4545709 100644
--- a/buildtools/wafsamba/samba_third_party.py
+++ b/buildtools/wafsamba/samba_third_party.py
@@ -18,7 +18,7 @@ Build.BuildContext.CHECK_POPT = CHECK_POPT
@conf
def CHECK_CMOCKA(conf):
- return conf.CHECK_BUNDLED_SYSTEM_PKG('cmocka', minversion='1.1.3')
+ return conf.CHECK_BUNDLED_SYSTEM_PKG('cmocka', minversion='1.1.8')
Build.BuildContext.CHECK_CMOCKA = CHECK_CMOCKA
diff --git a/lib/audit_logging/tests/audit_logging_error_test.c
b/lib/audit_logging/tests/audit_logging_error_test.c
index 12a81ff018d..595293b7dd1 100644
--- a/lib/audit_logging/tests/audit_logging_error_test.c
+++ b/lib/audit_logging/tests/audit_logging_error_test.c
@@ -43,6 +43,7 @@
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
+#include <stdint.h>
#include <cmocka.h>
#include "includes.h"
diff --git a/lib/audit_logging/tests/audit_logging_test.c
b/lib/audit_logging/tests/audit_logging_test.c
index 09238823399..ed189dabb8f 100644
--- a/lib/audit_logging/tests/audit_logging_test.c
+++ b/lib/audit_logging/tests/audit_logging_test.c
@@ -41,6 +41,7 @@
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
+#include <stdint.h>
#include <cmocka.h>
#include <string.h>
diff --git a/lib/compression/tests/test_lzx_huffman.c
b/lib/compression/tests/test_lzx_huffman.c
index 5016bcc6fce..2c31db160ce 100644
--- a/lib/compression/tests/test_lzx_huffman.c
+++ b/lib/compression/tests/test_lzx_huffman.c
@@ -24,6 +24,7 @@
#include <stdarg.h>
#include <stddef.h>
+#include <stdint.h>
#include <setjmp.h>
#include <cmocka.h>
#include <stdbool.h>
diff --git a/lib/compression/tests/test_lzxpress_plain.c
b/lib/compression/tests/test_lzxpress_plain.c
index 44b8f908511..3094197e75a 100644
--- a/lib/compression/tests/test_lzxpress_plain.c
+++ b/lib/compression/tests/test_lzxpress_plain.c
@@ -20,6 +20,7 @@
#include <stdarg.h>
#include <stddef.h>
+#include <stdint.h>
#include <setjmp.h>
#include <sys/stat.h>
#include <cmocka.h>
diff --git a/lib/ldb/tests/test_ldb_comparison_fold.c
b/lib/ldb/tests/test_ldb_comparison_fold.c
index 601cfe6c482..6c5a75ed74d 100644
--- a/lib/ldb/tests/test_ldb_comparison_fold.c
+++ b/lib/ldb/tests/test_ldb_comparison_fold.c
@@ -21,6 +21,7 @@
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
+#include <stdint.h>
#include <cmocka.h>
#include <stdbool.h>
#include "replace.h"
diff --git a/lib/pthreadpool/tests_cmocka.c b/lib/pthreadpool/tests_cmocka.c
index e6af8849f01..43fc29fded8 100644
--- a/lib/pthreadpool/tests_cmocka.c
+++ b/lib/pthreadpool/tests_cmocka.c
@@ -19,6 +19,7 @@
#include <errno.h>
#include <pthread.h>
+#include <stdint.h>
#include <setjmp.h>
#include <stdlib.h>
#include <string.h>
diff --git a/lib/util/tests/test_stable_sort.c
b/lib/util/tests/test_stable_sort.c
index ae4b1f3ea53..1231c3e80d4 100644
--- a/lib/util/tests/test_stable_sort.c
+++ b/lib/util/tests/test_stable_sort.c
@@ -21,6 +21,7 @@
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
+#include <stdint.h>
#include <cmocka.h>
#include <stdbool.h>
#include "replace.h"
diff --git a/libcli/drsuapi/tests/test_repl_decrypt.c
b/libcli/drsuapi/tests/test_repl_decrypt.c
index 996c6e6c042..7b0848f212a 100644
--- a/libcli/drsuapi/tests/test_repl_decrypt.c
+++ b/libcli/drsuapi/tests/test_repl_decrypt.c
@@ -36,6 +36,7 @@
#include <stdarg.h>
#include <stddef.h>
+#include <stdint.h>
#include <setjmp.h>
#include <cmocka.h>
diff --git a/libcli/ldap/tests/ldap_message_test.c
b/libcli/ldap/tests/ldap_message_test.c
index bea7b911846..f4cabd0d6dd 100644
--- a/libcli/ldap/tests/ldap_message_test.c
+++ b/libcli/ldap/tests/ldap_message_test.c
@@ -34,6 +34,7 @@
*/
#include <stdarg.h>
#include <stddef.h>
+#include <stdint.h>
#include <setjmp.h>
#include <cmocka.h>
diff --git a/libcli/security/tests/test_run_conditional_ace.c
b/libcli/security/tests/test_run_conditional_ace.c
index 70fe78c5352..881a1e6b6d9 100644
--- a/libcli/security/tests/test_run_conditional_ace.c
+++ b/libcli/security/tests/test_run_conditional_ace.c
@@ -20,6 +20,7 @@
#include <stdarg.h>
#include <stddef.h>
+#include <stdint.h>
#include <setjmp.h>
#include "cmocka.h"
diff --git a/libcli/security/tests/test_sddl_conditional_ace.c
b/libcli/security/tests/test_sddl_conditional_ace.c
index b1b9881db68..fd2473a8fff 100644
--- a/libcli/security/tests/test_sddl_conditional_ace.c
+++ b/libcli/security/tests/test_sddl_conditional_ace.c
@@ -20,6 +20,7 @@
#include <stdarg.h>
#include <stddef.h>
+#include <stdint.h>
#include <setjmp.h>
#include "cmocka.h"
diff --git a/source4/auth/tests/heimdal_unwrap_des.c
b/source4/auth/tests/heimdal_unwrap_des.c
index fbfe7782e7e..05c51b6a3a8 100644
--- a/source4/auth/tests/heimdal_unwrap_des.c
+++ b/source4/auth/tests/heimdal_unwrap_des.c
@@ -35,6 +35,7 @@
#include <stdarg.h>
#include <stddef.h>
+#include <stdint.h>
#include <setjmp.h>
#include <cmocka.h>
diff --git a/source4/dsdb/samdb/ldb_modules/tests/test_audit_log.c
b/source4/dsdb/samdb/ldb_modules/tests/test_audit_log.c
index aa14022f115..2862fa25f3f 100644
--- a/source4/dsdb/samdb/ldb_modules/tests/test_audit_log.c
+++ b/source4/dsdb/samdb/ldb_modules/tests/test_audit_log.c
@@ -20,6 +20,7 @@
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
+#include <stdint.h>
#include <unistd.h>
#include <cmocka.h>
diff --git a/source4/dsdb/samdb/ldb_modules/tests/test_audit_log_errors.c
b/source4/dsdb/samdb/ldb_modules/tests/test_audit_log_errors.c
index 35b07b7ec10..9557d7b43a8 100644
--- a/source4/dsdb/samdb/ldb_modules/tests/test_audit_log_errors.c
+++ b/source4/dsdb/samdb/ldb_modules/tests/test_audit_log_errors.c
@@ -24,6 +24,7 @@
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
+#include <stdint.h>
#include <unistd.h>
#include <cmocka.h>
diff --git a/source4/dsdb/samdb/ldb_modules/tests/test_audit_util.c
b/source4/dsdb/samdb/ldb_modules/tests/test_audit_util.c
index 44f7b7750c3..45856facbcd 100644
--- a/source4/dsdb/samdb/ldb_modules/tests/test_audit_util.c
+++ b/source4/dsdb/samdb/ldb_modules/tests/test_audit_util.c
@@ -20,6 +20,7 @@
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
+#include <stdint.h>
#include <unistd.h>
#include <cmocka.h>
diff --git a/source4/dsdb/samdb/ldb_modules/tests/test_encrypted_secrets.c
b/source4/dsdb/samdb/ldb_modules/tests/test_encrypted_secrets.c
index e639d4cbb0a..425f4be5e3c 100644
--- a/source4/dsdb/samdb/ldb_modules/tests/test_encrypted_secrets.c
+++ b/source4/dsdb/samdb/ldb_modules/tests/test_encrypted_secrets.c
@@ -20,6 +20,7 @@
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
+#include <stdint.h>
#include <unistd.h>
#include <cmocka.h>
diff --git a/source4/dsdb/samdb/ldb_modules/tests/test_group_audit.c
b/source4/dsdb/samdb/ldb_modules/tests/test_group_audit.c
index f7075f3485e..bd66451f355 100644
--- a/source4/dsdb/samdb/ldb_modules/tests/test_group_audit.c
+++ b/source4/dsdb/samdb/ldb_modules/tests/test_group_audit.c
@@ -20,6 +20,7 @@
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
+#include <stdint.h>
#include <unistd.h>
#include <cmocka.h>
diff --git a/source4/dsdb/samdb/ldb_modules/tests/test_group_audit_errors.c
b/source4/dsdb/samdb/ldb_modules/tests/test_group_audit_errors.c
index ea9f2b7db79..eb6230291f7 100644
--- a/source4/dsdb/samdb/ldb_modules/tests/test_group_audit_errors.c
+++ b/source4/dsdb/samdb/ldb_modules/tests/test_group_audit_errors.c
@@ -24,6 +24,7 @@
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
+#include <stdint.h>
#include <unistd.h>
#include <cmocka.h>
diff --git a/source4/dsdb/samdb/ldb_modules/tests/test_unique_object_sids.c
b/source4/dsdb/samdb/ldb_modules/tests/test_unique_object_sids.c
index 2d37d53a066..f25cd5f1db9 100644
--- a/source4/dsdb/samdb/ldb_modules/tests/test_unique_object_sids.c
+++ b/source4/dsdb/samdb/ldb_modules/tests/test_unique_object_sids.c
@@ -20,6 +20,7 @@
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
+#include <stdint.h>
#include <unistd.h>
#include <cmocka.h>
diff --git a/source4/kdc/tests/db-glue-test.c b/source4/kdc/tests/db-glue-test.c
index 2ff528b129c..326a96314aa 100644
--- a/source4/kdc/tests/db-glue-test.c
+++ b/source4/kdc/tests/db-glue-test.c
@@ -33,11 +33,12 @@
*
*/
+#include <stdint.h>
#include <setjmp.h>
#include <stdarg.h>
#include <stddef.h>
-#include "../../../third_party/cmocka/cmocka.h"
+#include <cmocka.h>
#include "../db-glue.c"
#include "krb5-protos.h"
diff --git a/source4/kdc/tests/sdb_to_hdb_test.c
b/source4/kdc/tests/sdb_to_hdb_test.c
index 58281d7926c..1b82aba47c6 100644
--- a/source4/kdc/tests/sdb_to_hdb_test.c
+++ b/source4/kdc/tests/sdb_to_hdb_test.c
@@ -36,8 +36,9 @@
#include <setjmp.h>
#include <stdarg.h>
#include <stddef.h>
+#include <stdint.h>
-#include "../../../third_party/cmocka/cmocka.h"
+#include <cmocka.h>
#include "../sdb_to_hdb.c"
#include "hdb_asn1.h"
diff --git a/source4/rpc_server/tests/rpc_dns_server_dnsutils_test.c
b/source4/rpc_server/tests/rpc_dns_server_dnsutils_test.c
index cdb245ed020..46ede51aac8 100644
--- a/source4/rpc_server/tests/rpc_dns_server_dnsutils_test.c
+++ b/source4/rpc_server/tests/rpc_dns_server_dnsutils_test.c
@@ -36,6 +36,7 @@
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
+#include <stdint.h>
#include <cmocka.h>
diff --git a/testsuite/unittests/test_krb5_samba.c
b/testsuite/unittests/test_krb5_samba.c
index 8b7e843b85f..ccc57775c23 100644
--- a/testsuite/unittests/test_krb5_samba.c
+++ b/testsuite/unittests/test_krb5_samba.c
@@ -1,5 +1,6 @@
#include <stdarg.h>
#include <stddef.h>
+#include <stdint.h>
#include <setjmp.h>
#include <cmocka.h>
diff --git a/testsuite/unittests/test_lib_util_modules.c
b/testsuite/unittests/test_lib_util_modules.c
index 647fc1fb82d..208747ad1d0 100644
--- a/testsuite/unittests/test_lib_util_modules.c
+++ b/testsuite/unittests/test_lib_util_modules.c
@@ -1,5 +1,6 @@
#include <stdarg.h>
#include <stddef.h>
+#include <stdint.h>
#include <setjmp.h>
#include <cmocka.h>
diff --git a/third_party/cmocka/cmocka.c b/third_party/cmocka/cmocka.c
index b21fe15536c..1ea32ebc6bf 100644
--- a/third_party/cmocka/cmocka.c
+++ b/third_party/cmocka/cmocka.c
@@ -42,7 +42,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <stdbool.h>
#include <time.h>
+#include <float.h>
+#include <errno.h>
+#include <limits.h>
/*
* This allows to add a platform specific header file. Some embedded platforms
@@ -69,7 +73,9 @@
#define MALLOC_ALLOC_PATTERN 0xBA
#define MALLOC_FREE_PATTERN 0xCD
/* Alignment of allocated blocks. NOTE: This must be base2. */
+#ifndef MALLOC_ALIGNMENT
#define MALLOC_ALIGNMENT sizeof(size_t)
+#endif
/* Printf formatting for source code locations. */
#define SOURCE_LOCATION_FORMAT "%s:%u"
@@ -107,37 +113,17 @@
/*
- * Declare and initialize the pointer member of ValuePointer variable name
- * with ptr.
+ * Declare and initialize a LargestIntegralType variable name
+ * with value the conversion of ptr.
*/
#define declare_initialize_value_pointer_pointer(name, ptr) \
- ValuePointer name ; \
- name.value = 0; \
- name.x.pointer = (void*)(ptr)
-
-/*
- * Declare and initialize the value member of ValuePointer variable name
- * with val.
- */
-#define declare_initialize_value_pointer_value(name, val) \
- ValuePointer name ; \
- name.value = val
+ LargestIntegralType name ; \
+ name = (LargestIntegralType) (uintptr_t) ptr
-/* Cast a LargestIntegralType to pointer_type via a ValuePointer. */
+/* Cast a LargestIntegralType to pointer_type. */
#define cast_largest_integral_type_to_pointer( \
pointer_type, largest_integral_type) \
- ((pointer_type)((ValuePointer*)&(largest_integral_type))->x.pointer)
-
-/* Used to cast LargetIntegralType to void* and vice versa. */
-typedef union ValuePointer {
- LargestIntegralType value;
- struct {
-#if defined(WORDS_BIGENDIAN) && (WORDS_SIZEOF_VOID_P == 4)
- unsigned int padding;
-#endif
- void *pointer;
- } x;
-} ValuePointer;
+ ((pointer_type)(uintptr_t)(largest_integral_type))
/* Doubly linked list node. */
typedef struct ListNode {
@@ -272,8 +258,6 @@ static enum cm_message_output cm_get_output(void);
static int cm_error_message_enabled = 1;
static CMOCKA_THREAD char *cm_error_message;
-void cm_print_error(const char * const format, ...) CMOCKA_PRINTF_ATTRIBUTE(1,
2);
-
/*
* Keeps track of the calling context returned by setenv() so that the fail()
* method can jump out of a test.
@@ -312,6 +296,8 @@ static enum cm_message_output global_msg_output =
CM_OUTPUT_STDOUT;
static const char *global_test_filter_pattern;
+static const char *global_skip_filter_pattern;
+
#ifndef _WIN32
/* Signals caught by exception_handler(). */
static const int exception_signals[] = {
@@ -411,6 +397,9 @@ void _skip(const char * const file, const int line)
cm_print_error(SOURCE_LOCATION_FORMAT ": Skipped!\n", file, line);
global_skip_test = 1;
exit_test(1);
+
+ /* Unreachable */
+ exit(-1);
}
/* Initialize a SourceLocation structure. */
@@ -446,32 +435,41 @@ static int c_strreplace(char *src,
{
char *p = NULL;
+ // Terminate if there is no valid data
+ if (src == NULL || src_len == 0 || pattern == NULL || repl == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
p = strstr(src, pattern);
+ /* There is nothing to replace */
if (p == NULL) {
- return -1;
+ return 0;
}
+ const size_t pattern_len = strlen(pattern);
+ const size_t repl_len = strlen(repl);
do {
- size_t of = p - src;
+ size_t offset = p - src;
size_t l = strlen(src);
- size_t pl = strlen(pattern);
- size_t rl = strlen(repl);
/* overflow check */
- if (src_len <= l + MAX(pl, rl) + 1) {
+ if (src_len <= l + MAX(pattern_len, repl_len) + 1) {
return -1;
}
- if (rl != pl) {
- memmove(src + of + rl, src + of + pl, l - of - pl + 1);
+ if (repl_len != pattern_len) {
+ memmove(src + offset + repl_len,
+ src + offset + pattern_len,
+ l - offset - pattern_len + 1);
}
- memcpy(src + of, repl, rl);
+ memcpy(src + offset, repl, repl_len);
if (str_replaced != NULL) {
*str_replaced = 1;
}
- p = strstr(src, pattern);
+ p = strstr(src + offset + repl_len, pattern);
} while (p != NULL);
return 0;
@@ -567,7 +565,7 @@ static void fail_if_leftover_values(const char *test_name) {
remove_always_return_values_from_list(&global_call_ordering_head);
if (check_for_leftover_values_list(&global_call_ordering_head,
- "%s function was expected to be called but was not not.\n")) {
+ "%s function was expected to be called but was not.\n")) {
error_occurred = 1;
}
if (error_occurred) {
@@ -717,9 +715,16 @@ static void free_symbol_map_value(const void *value,
SymbolMapValue * const map_value = (SymbolMapValue*)value;
const LargestIntegralType children =
cast_ptr_to_largest_integral_type(cleanup_value_data);
assert_non_null(value);
- list_free(&map_value->symbol_values_list_head,
- children ? free_symbol_map_value : free_value,
- (void *) ((uintptr_t)children - 1));
+ if (children == 0) {
+ list_free(&map_value->symbol_values_list_head,
+ free_value,
+ NULL);
+ } else {
+ list_free(&map_value->symbol_values_list_head,
+ free_symbol_map_value,
+ (void *)((uintptr_t)children - 1));
+ }
+
free(map_value);
}
@@ -898,7 +903,7 @@ static size_t check_for_leftover_values_list(const ListNode
* head,
child_node = child_node->next, ++leftover_count) {
const FuncOrderingValue *const o =
(const FuncOrderingValue*) child_node->value;
- cm_print_error(error_message, o->function);
+ cm_print_error("%s: %s", error_message, o->function);
cm_print_error(SOURCE_LOCATION_FORMAT
": note: remaining item was declared here\n",
o->location.file, o->location.line);
@@ -930,7 +935,7 @@ static size_t check_for_leftover_values(
if (!list_empty(child_list)) {
if (number_of_symbol_names == 1) {
const ListNode *child_node;
- cm_print_error(error_message, value->symbol_name);
--
Samba Shared Repository