summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/tests/util-tests.c12
-rw-r--r--src/util/util_safealign.h5
2 files changed, 8 insertions, 9 deletions
diff --git a/src/tests/util-tests.c b/src/tests/util-tests.c
index 4b0d5009..9af12081 100644
--- a/src/tests/util-tests.c
+++ b/src/tests/util-tests.c
@@ -388,14 +388,14 @@ END_TEST
START_TEST(test_size_t_overflow)
{
fail_unless(!SIZE_T_OVERFLOW(1, 1), "unexpected overflow");
- fail_unless(!SIZE_T_OVERFLOW(SIZE_T_MAX, 0), "unexpected overflow");
- fail_unless(!SIZE_T_OVERFLOW(SIZE_T_MAX-10, 10), "unexpected overflow");
- fail_unless(SIZE_T_OVERFLOW(SIZE_T_MAX, 1), "overflow not detected");
- fail_unless(SIZE_T_OVERFLOW(SIZE_T_MAX, SIZE_T_MAX),
+ fail_unless(!SIZE_T_OVERFLOW(SIZE_MAX, 0), "unexpected overflow");
+ fail_unless(!SIZE_T_OVERFLOW(SIZE_MAX-10, 10), "unexpected overflow");
+ fail_unless(SIZE_T_OVERFLOW(SIZE_MAX, 1), "overflow not detected");
+ fail_unless(SIZE_T_OVERFLOW(SIZE_MAX, SIZE_MAX),
"overflow not detected");
- fail_unless(SIZE_T_OVERFLOW(SIZE_T_MAX, ULLONG_MAX),
+ fail_unless(SIZE_T_OVERFLOW(SIZE_MAX, ULLONG_MAX),
"overflow not detected");
- fail_unless(SIZE_T_OVERFLOW(SIZE_T_MAX, -10), "overflow not detected");
+ fail_unless(SIZE_T_OVERFLOW(SIZE_MAX, -10), "overflow not detected");
}
END_TEST
diff --git a/src/util/util_safealign.h b/src/util/util_safealign.h
index d1d7a486..e7f34e14 100644
--- a/src/util/util_safealign.h
+++ b/src/util/util_safealign.h
@@ -30,11 +30,10 @@
#define _UTIL_SAFEALIGN_H
#include <string.h>
-
-#define SIZE_T_MAX ((size_t) -1)
+#include <stdint.h>
#define SIZE_T_OVERFLOW(current, add) \
- (((size_t)(add)) > (SIZE_T_MAX - ((size_t)(current))))
+ (((size_t)(add)) > (SIZE_MAX - ((size_t)(current))))
static inline void
safealign_memcpy(void *dest, const void *src, size_t n, size_t *counter)