2.3.12 statuscahe off_t size bug

John Capo jc at irbs.com
Tue Apr 22 17:10:03 EDT 2008


Found a bug handling the off_t index_size value in the statuscache
code.  The code assumes off_t is a 32 bits and the message count gets
written as 0.

(gdb) p *scdata
$22 = {statusitems = 63, index_mtime = 1208893338, index_ino = 1974639, index_size = 6581528, 
  messages = 74789, recent = 174, uidnext = 1547527, uidvalidity = 1125360596, unseen = 74743, 
  highestmodseq = 0}
(gdb) n
247         r = DB->store(statuscachedb, key, keylen, data, datalen, NULL);
(gdb) p data
$23 = "3 63 1208893338 1974639 6581528 0 74789 174 1547527 1125360596 74743\000

The attached patch assumes off_t is 64 bits.  Are there any 32 bit
off_t systems left?

John Capo

-------------- next part --------------
--- ../cyrus-imapd-2.3.12/imap/statuscache_db.c	Mon Mar 24 13:09:20 2008
+++ imap/statuscache_db.c	Tue Apr 22 16:00:22 2008
@@ -187,7 +187,7 @@
     if (p < dend) scdata->statusitems = (unsigned) strtol(p, &p, 10);
     if (p < dend) scdata->index_mtime = strtol(p, &p, 10);
     if (p < dend) scdata->index_ino = strtoul(p, &p, 10);
-    if (p < dend) scdata->index_size = strtoul(p, &p, 10);
+    if (p < dend) scdata->index_size = strtoull(p, &p, 10);
     if (p < dend) scdata->messages = strtoul(p, &p, 10);
     if (p < dend) scdata->recent = (unsigned) strtoul(p, &p, 10);
     if (p < dend) scdata->uidnext = strtoul(p, &p, 10);
@@ -233,7 +233,7 @@
     char *key = statuscache_buildkey(mboxname, userid, &keylen);
 
     datalen = snprintf(data, sizeof(data),
-		       "%u %u %ld %lu %lu %lu %u %lu %lu %u " MODSEQ_FMT,
+		       "%u %u %ld %lu %llu %lu %u %lu %lu %u " MODSEQ_FMT,
 		       STATUSCACHE_VERSION, scdata->statusitems,
 		       scdata->index_mtime, scdata->index_ino,
 		       scdata->index_size, scdata->messages,


More information about the Cyrus-devel mailing list