Open brong opened 13 years ago
From: OBATA Akio
On NetBSD-current (will be NetBSD-6.0), time_t is 64-bits. But I feel time_t is expected as 32-bits in Cyrus-IMAP sources. I'm not sure whether it should be exactly 32-bits (for protocol reason? from IMAP spec, and doc/internal/replication_protocol.html) or native time_t value for any case.
For example, in imap/mailbox.c:1892, time_t is treated as "%lu" for snprintf. In this case, it will crash because a half of record->internaldate will be used as the next "%s". Then, how to fix? record->* should be unsigned long? or introduce platform depend TIME_T_FMT?
From: OBATA Akio
Not just 64-bits and 32-bits time_t issue, time_t != long int platforms (32-bits arch, but time_t is 64-bits).
Attachment-Id: 1536 From: Antoine Jacoutot Type: text/plain File: patch-imap_mailbox_c.txt
cast time_t to long long
From: Antoine Jacoutot
On OpenBSD we are using this patch to prevent a crash when delivering with cyrusv2 and sendmail. IIRC casting time_t to long long is the most portable way to represent time values.
From: OBATA Akio
(In reply to comment #3) > On OpenBSD we are using this patch to prevent a crash when delivering with > cyrusv2 and sendmail. IIRC casting time_t to long long is the most portable way > to represent time values.
I'm using cyrusimap in pkgsrc, i.e. need multiple platform support. Moreover, current souce codes use "HAVE_LONG_LONG_INT" switch in various location. So unconditional cast to "unsigned long long" is probably not acceptable.
Anyway, you should also patch to log_record() in imap/sync_client.c, but you can find "unsinged long" is used by sieve_upload() as a argment. It may also be changed to "time_t", because "last_updated" is passed to dlist_date(), and its argment is defined as "time_t". Other such mismatch also may be found.
From: OBATA Akio
Here are current our patches, using modseq_t and MODSEQ_FMT, same as imap/dlist.c:
--- imap/sync_client.c.orig 2012-12-01 19:57:54.000000000 +0000 +++ imap/sync_client.c @@ -573,7 +573,7 @@ static int folder_unannotation(const cha / ====================================================================== /
static int sieve_upload(const char userid, const char filename,
--- imap/mailbox.c.orig 2012-12-01 19:57:54.000000000 +0000 +++ imap/mailbox.c @@ -1960,10 +1960,10 @@ bit32 make_sync_crc(struct mailbox *mail flagcrc ^= crc32_cstring(buf); }
(modseq_t)record->internaldate, message_guid_encode(&record->guid));
return crc32_cstring(buf);
From: Antoine Jacoutot
> So unconditional cast to "unsigned long long" is probably not acceptable.
Well as far as I know casting to long long it's the only way that it will work on most UNIX OSes. Granted that may require more work in the cyrus case.
> Anyway, you should also patch to log_record() in imap/sync_client.c, > but you can find "unsinged long" is used by sieve_upload() as a argment. > It may also be changed to "time_t", because "last_updated" is passed to > dlist_date(), and its argment is defined as "time_t". > Other such mismatch also may be found.
Yeah unfortunately there are lots of places where the use of time_t is wrong... I have no time to dig but I will have a look at your patches for the OpenBSD package at least. Since this bug was opened almost 4 years ago, I doubt it is of interested to the devs.
Thanks.
From: OBATA Akio Bugzilla-Id: 3376 Version: 2.4.6 Owner: Ken Murchison