# Small patch for Cyrus 2.1.16 which fixes THREAD command. subj is a # Cyrus CACHE_ITEM [htonl(size) followed by byte stream] not C string. # Existing code mostly works as next cache item will include a '\0' in the # first few characters. SIGBUS if mmapped file ends on precise page # boundary (4096 bytes on Linux). # diff -ur cyrus-imapd-2.1.16-DIST/imap/index.c cyrus-imapd-2.1.16/imap/index.c --- cyrus-imapd-2.1.16-DIST/imap/index.c 2003-08-14 17:20:32.000000000 +0100 +++ cyrus-imapd-2.1.16/imap/index.c 2004-04-18 15:47:58.000000000 +0100 @@ -3213,7 +3213,17 @@ cur->from = get_localpart_addr(from+4); break; case SORT_SUBJECT: - cur->xsubj = index_extract_subject(subj+4, &cur->is_refwd); + { + int len = CACHE_ITEM_LEN(subj); + char *t = xmalloc(len+1); + + memcpy(t, subj + CACHE_ITEM_SIZE_SKIP, len); + t[len] = '\0'; + + cur->xsubj = index_extract_subject(t, &cur->is_refwd); + + free(t); + } cur->xsubj_hash = hash(cur->xsubj); break; case SORT_TO: