mbexamine and block size cache files

John Capo jc at irbs.com
Tue Aug 19 19:55:03 EDT 2008


mbexamine depends on cache file entries being NULL terminated and
some (many) are not.  This problem cache file's size is a multiple
of the filsystem block size resulting from a reconstruct -G.

  -rw-------  1 cyrus  cyrus  4096 Aug 19 18:44 cyrus.cache

End of the cache file hex dump.

  0FC0  3E00 0000 0000 0000 0000 0000 0000 0030 [>..............0]
  0FD0  222A 2A2A 6A70 6D74 6D74 6364 732A 2A2A ["***jpmtmtcds***]
  0FE0  7765 656B 6C79 6368 616E 6765 732D 6A61 [weeklychanges-ja]
  0FF0  6E75 6172 7932 326E 6474 6F32 3574 6822 [nuary22ndto25th"]

Mbexamine cores attempting to print that subject due to the missing
NULL.

    To>{21}<bobby at example.com>
    Cc>{0}
   Bcc>{0}
Bus error

Mbexamine appears to be the only thing that depends on NULL terminated
strings in the cache file.  Quick fix patch attached that lets me
get on with the task at hand.

    To>{21}<bobby at example.com>
    Cc>{0}
   Bcc>{0}
Subjct>{48}"***jpmtmtcds***weeklychanges-january22ndto25th"

John Capo


-------------- next part --------------
Index: imap/mbexamine.c
===================================================================
RCS file: /usr/local/CVS/src/cyrus-imapd/imap/mbexamine.c,v
retrieving revision 1.3
diff -u -r1.3 mbexamine.c
--- imap/mbexamine.c	25 Apr 2008 14:29:50 -0000	1.3
+++ imap/mbexamine.c	19 Aug 2008 23:22:58 -0000
@@ -396,8 +396,14 @@
 	printf("   Bcc>{%d}%s\n", CACHE_ITEM_LEN(cacheitem),
 	       cacheitem + CACHE_ITEM_SIZE_SKIP);
 	cacheitem = CACHE_ITEM_NEXT(cacheitem);
-	printf("Subjct>{%d}%s\n", CACHE_ITEM_LEN(cacheitem),
-	       cacheitem + CACHE_ITEM_SIZE_SKIP);
+	printf("Subjct>{%d}", CACHE_ITEM_LEN(cacheitem));
+	fflush(stdout);
+
+	if (CACHE_ITEM_LEN(cacheitem))
+	    fwrite(cacheitem + CACHE_ITEM_SIZE_SKIP, CACHE_ITEM_LEN(cacheitem), 1, stdout);
+
+	printf("\n");
+	fflush(stdout);
 
 	if(flag) break;
     }


More information about the Cyrus-devel mailing list