From 6e065b7d467ed78b1fc3151f805ba46fbe92f539 Mon Sep 17 00:00:00 2001 From: Paul Howarth Date: Thu, 26 Jun 2025 10:39:40 +0100 Subject: [PATCH 1/2] lib: fix test-event-filter for systems with 32-bit long On systems such as i686 with 32-bit long integers, expressions such as 60L * 60 * 1000 * 1000 (3600000000) overflow the maximum value of 2147483647, causing the test to fail. This can be fixed by using a "long long" (which is used for intmax_t) instead, e.g. 60LL * 60 * 1000 * 1000 --- src/lib/test-event-filter.c | 52 ++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/lib/test-event-filter.c b/src/lib/test-event-filter.c index d6eebb92368..1158795ec59 100644 --- a/src/lib/test-event-filter.c +++ b/src/lib/test-event-filter.c @@ -1003,32 +1003,32 @@ static void test_event_filter_interval_values(void) { "field > 1mins", 60 * 1000 * 1000, FALSE }, { "field < 1mins", 60 * 1000 * 1000, FALSE }, - { "field = 1hours", 60L * 60 * 1000 * 1000, TRUE }, - { "field = 1h", 60L * 60 * 1000 * 1000, TRUE }, - { "field = 3600000000", 60L * 60 * 1000 * 1000, TRUE }, - { "field >= 1hours", 60L * 60 * 1000 * 1000, TRUE }, - { "field <= 1hours", 60L * 60 * 1000 * 1000, TRUE }, - { "field > 1mins", 60L * 60 * 1000 * 1000, TRUE }, - { "field > 1hours", 60L * 60 * 1000 * 1000, FALSE }, - { "field < 1hours", 60L * 60 * 1000 * 1000, FALSE }, - - { "field = 1days", 24L * 60 * 60 * 1000 * 1000, TRUE }, - { "field = 1d", 24L * 60 * 60 * 1000 * 1000, TRUE }, - { "field = 86400000000", 24L * 60 * 60 * 1000 * 1000, TRUE }, - { "field >= 1days", 24L * 60 * 60 * 1000 * 1000, TRUE }, - { "field <= 1days", 24L * 60 * 60 * 1000 * 1000, TRUE }, - { "field > 1hours", 24L * 60 * 60 * 1000 * 1000, TRUE }, - { "field > 1days", 24L * 60 * 60 * 1000 * 1000, FALSE }, - { "field < 1days", 24L * 60 * 60 * 1000 * 1000, FALSE }, - - { "field = 1weeks", 7L * 24 * 60 * 60 * 1000 * 1000, TRUE }, - { "field = 1w", 7L * 24 * 60 * 60 * 1000 * 1000, TRUE }, - { "field = 604800000000", 7L * 24 * 60 * 60 * 1000 * 1000, TRUE }, - { "field >= 1weeks", 7L * 24 * 60 * 60 * 1000 * 1000, TRUE }, - { "field <= 1weeks", 7L * 24 * 60 * 60 * 1000 * 1000, TRUE }, - { "field > 1days", 7L * 24 * 60 * 60 * 1000 * 1000, TRUE }, - { "field > 1weeks", 7L * 24 * 60 * 60 * 1000 * 1000, FALSE }, - { "field < 1weeks", 7L * 24 * 60 * 60 * 1000 * 1000, FALSE }, + { "field = 1hours", 60LL * 60 * 1000 * 1000, TRUE }, + { "field = 1h", 60LL * 60 * 1000 * 1000, TRUE }, + { "field = 3600000000", 60LL * 60 * 1000 * 1000, TRUE }, + { "field >= 1hours", 60LL * 60 * 1000 * 1000, TRUE }, + { "field <= 1hours", 60LL * 60 * 1000 * 1000, TRUE }, + { "field > 1mins", 60LL * 60 * 1000 * 1000, TRUE }, + { "field > 1hours", 60LL * 60 * 1000 * 1000, FALSE }, + { "field < 1hours", 60LL * 60 * 1000 * 1000, FALSE }, + + { "field = 1days", 24LL * 60 * 60 * 1000 * 1000, TRUE }, + { "field = 1d", 24LL * 60 * 60 * 1000 * 1000, TRUE }, + { "field = 86400000000", 24LL * 60 * 60 * 1000 * 1000, TRUE }, + { "field >= 1days", 24LL * 60 * 60 * 1000 * 1000, TRUE }, + { "field <= 1days", 24LL * 60 * 60 * 1000 * 1000, TRUE }, + { "field > 1hours", 24LL * 60 * 60 * 1000 * 1000, TRUE }, + { "field > 1days", 24LL * 60 * 60 * 1000 * 1000, FALSE }, + { "field < 1days", 24LL * 60 * 60 * 1000 * 1000, FALSE }, + + { "field = 1weeks", 7LL * 24 * 60 * 60 * 1000 * 1000, TRUE }, + { "field = 1w", 7LL * 24 * 60 * 60 * 1000 * 1000, TRUE }, + { "field = 604800000000", 7LL * 24 * 60 * 60 * 1000 * 1000, TRUE }, + { "field >= 1weeks", 7LL * 24 * 60 * 60 * 1000 * 1000, TRUE }, + { "field <= 1weeks", 7LL * 24 * 60 * 60 * 1000 * 1000, TRUE }, + { "field > 1days", 7LL * 24 * 60 * 60 * 1000 * 1000, TRUE }, + { "field > 1weeks", 7LL * 24 * 60 * 60 * 1000 * 1000, FALSE }, + { "field < 1weeks", 7LL * 24 * 60 * 60 * 1000 * 1000, FALSE }, }; struct event_filter *filter; From da913e94c8a00b9f76ddfc5307939f9908d1bdb7 Mon Sep 17 00:00:00 2001 From: Paul Howarth Date: Thu, 26 Jun 2025 10:47:35 +0100 Subject: [PATCH 2/2] lib-imap: fix for systems with signed 32-bit time_t The code and tests have some hard-coded values based on the size of time_t but they don't take into account whether or not time_t is a signed value. On systems such as i686 with time_t as a signed 32-bit integer, the maximum value is the same as an unsigned 31-bit integer. Tweak the configure test to treat 32-bit signed as 31 bits. --- m4/gmtime_max.m4 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/m4/gmtime_max.m4 b/m4/gmtime_max.m4 index da272d0c580..d2501c1776e 100644 --- a/m4/gmtime_max.m4 +++ b/m4/gmtime_max.m4 @@ -1,5 +1,6 @@ dnl * how large time_t values does gmtime() accept? AC_DEFUN([DOVECOT_GMTIME_MAX], [ + AC_REQUIRE([DOVECOT_TIME_T]) AC_CACHE_CHECK([how large time_t values gmtime() accepts],i_cv_gmtime_max_time_t,[ AC_RUN_IFELSE([AC_LANG_PROGRAM([[ #include @@ -20,6 +21,12 @@ AC_DEFUN([DOVECOT_GMTIME_MAX], [ Let's just do the same as Cyrus folks and limit it to 40 bits. */ bits = 40; } + #ifdef TIME_T_SIGNED + if (bits == 32) { + /* Signed 32-bit time_t is essentially the same as unsigned 31-bit time_t */ + bits = 31; + } + #endif f = fopen("conftest.temp", "w"); if (f == NULL) {