Cores in Fetch binary of msg file is deleted.

Esh, Thomas D (Tom) esh at
Sun Sep 24 23:35:43 EDT 2006

We are using cyrus-imapd-2.3.7.
We were getting imapd core dumps in  "fetch binary[n]" commands
if another imap session had deleted the msg file during the current imap session.  
Here is the backtrack of the core:
#0  charset_readbase64 (state=0xbfffcdf0, buf=0x8157980 "???y\025\b\b56@",
    size=32022) at charset.c:1174
#1  0x080939d0 in charset_decode_mimebody (
    msg_base=0x62e <Address 0x62e out of bounds>, len=32022, encoding=2,
    retval=0xbfffd678, alloced=0, outlen=0xbfffd69c) at charset.c:877
#2  0x0806bc47 in index_fetchsection (resp=0xbfffd730 "* 1 FETCH (BINARY[2] ",
    msg_base=0x0, msg_size=0, format=0, section=0x8157948 "2]",
    cacheitem=0x4225e388 <Address 0x4225e388 out of bounds>, size=32022,
    start_octet=0, octet_count=0) at index.c:1950
#3  0x0806c915 in index_fetchreply (mailbox=0x813c540, msgno=1,
    rock=0xbfffd8e0) at index.c:2638
#4  0x08065c25 in index_forsequence (mailbox=0x813c540, sequence=0x8154981 "",
    usinguid=0, proc=0x806bda0 <index_fetchreply>, rock=0xbfffd8e0,
    fetchedsomething=0xbfffd85c) at index.c:1731
#5  0x080585dc in cmd_fetch (tag=0x81548a0 "00000005", sequence=0x8154980 "1",
The problem is msg_base is zero, because the file open in mailbox_map_message fails because
the file doesn't exist.
The fix is to change index.c line 1946 from:
            if ((p = strstr(resp, "BINARY"))) { 
            if (msg_base && (p = strstr(resp, "BINARY"))) { 
This will cause the response to be something like this:
1 fetch 2 binary[1]
* OK Message 2 no longer exists
* 2 FETCH (BINARY[1] "")
1 OK Completed (0.000 sec)

Thomas D. Esh             Email: esh at
Lucent Technologies         MMS: 7403342319 at
Room 3B-316                Work: 614-367-4390
6200 East Broad Street   Mobile: 740-334-2319
Columbus, OH 43213         Home: 740-321-1245 
Our lives begin to end the day we become silent about 
things that matter. -- Martin Luther King, Jr. 

-------------- next part --------------
An HTML attachment was scrubbed...

More information about the Cyrus-devel mailing list