summaryrefslogtreecommitdiff
path: root/tests/test_utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_utils.c')
-rw-r--r--tests/test_utils.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/tests/test_utils.c b/tests/test_utils.c
index 0b00005..9f070e9 100644
--- a/tests/test_utils.c
+++ b/tests/test_utils.c
@@ -1,8 +1,8 @@
/*
* cryptsetup library API test utilities
*
- * Copyright (C) 2009-2020 Red Hat, Inc. All rights reserved.
- * Copyright (C) 2009-2020 Milan Broz
+ * Copyright (C) 2009-2021 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2009-2021 Milan Broz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -95,6 +95,14 @@ void check_equal(int line, const char *func, int64_t x, int64_t y)
exit(-1);
}
+void check_ge_equal(int line, const char *func, int64_t x, int64_t y)
+{
+ printf("FAIL line %d [%s]: expected greater or equal values differs: %"
+ PRIi64 " < %" PRIi64 "\n", line, func, x, y);
+ _cleanup();
+ exit(-1);
+}
+
void check_null(int line, const char *func, const void *x)
{
if (x) {
@@ -279,7 +287,14 @@ void global_log_callback(int level, const char *msg, void *usrptr)
if (level <= CRYPT_LOG_DEBUG)
return;
- strncat(global_log, msg, sizeof(global_log) - strlen(global_log));
+ len = strlen(global_log);
+
+ if (len + strlen(msg) > sizeof(global_log)) {
+ printf("Log buffer is too small, fix the test.\n");
+ return;
+ }
+
+ strncat(global_log, msg, sizeof(global_log) - len);
global_lines++;
if (level == CRYPT_LOG_ERROR) {
len = strlen(msg);