[dovecot-cvs] dovecot/src/lib-index mail-index-open.c,1.21,1.22 mail-index.c,1.77,1.78 mail-index.h,1.58,1.59
cras at procontrol.fi
cras at procontrol.fi
Thu Jan 2 13:29:26 EET 2003
Update of /home/cvs/dovecot/src/lib-index
In directory danu:/tmp/cvs-serv19287/lib-index
Modified Files:
mail-index-open.c mail-index.c mail-index.h
Log Message:
Make sure UIDs won't wrap around unexpectedly.
Index: mail-index-open.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index-open.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- mail-index-open.c 19 Dec 2002 01:02:35 -0000 1.21
+++ mail-index-open.c 2 Jan 2003 11:29:24 -0000 1.22
@@ -139,7 +139,7 @@
index->first_recent_uid = hdr->last_nonrecent_uid+1;
}
- if (hdr->next_uid >= INT_MAX-1024) {
+ if (hdr->next_uid >= MAX_ALLOWED_UID - 1000) {
/* UID values are getting too high, rebuild index */
index->set_flags |= MAIL_INDEX_FLAG_REBUILD;
}
Index: mail-index.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index.c,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -d -r1.77 -r1.78
--- mail-index.c 21 Dec 2002 22:39:15 -0000 1.77
+++ mail-index.c 2 Jan 2003 11:29:24 -0000 1.78
@@ -980,6 +980,13 @@
{
i_assert(rec->uid == 0);
+ if (index->header->next_uid == MAX_ALLOWED_UID) {
+ index->set_flags |= MAIL_INDEX_FLAG_REBUILD;
+ index_set_error(index, "Reached maximum UID in mailbox %s, "
+ "rebuilding index", index->filepath);
+ return FALSE;
+ }
+
index->header->messages_count++;
rec->uid = index->header->next_uid++;
Index: mail-index.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index.h,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- mail-index.h 20 Dec 2002 07:53:52 -0000 1.58
+++ mail-index.h 2 Jan 2003 11:29:24 -0000 1.59
@@ -478,6 +478,9 @@
int mail_index_compress_data(MailIndex *index);
int mail_index_truncate(MailIndex *index);
+/* Maximum allowed UID number. */
+#define MAX_ALLOWED_UID 4294967295U /* 2^32 - 1 */
+
/* Max. mmap()ed size for a message */
#define MAIL_MMAP_BLOCK_SIZE (1024*256)
/* Block size when read()ing message. */
More information about the dovecot-cvs
mailing list