<<< Date Index >>>     <<< Thread Index >>>

crash in imap_expunge_mailbox (similar to #2175)



Along the same lines as bug #2175, I got a crash somewhere else in the imap support, for a 
similar reason. This crash was in imap_expunge_mailbox, inside a loop through 
idata->ctx->hdrs. For whatever reason, it looks like idata->ctx->msgcount isn't 
always an accurate count of how many hdrs have been stored in idata->ctx->hdrs.

Here's the gdb output:

(gdb) bt
#0  0x000d009c in imap_expunge_mailbox (idata=0x1143b60) at imap.c:255
#1  0x000dbf04 in imap_cmd_finish (idata=0x1143b60) at command.c:287
#2  0x000dbac4 in imap_cmd_step (idata=0x1143b60) at command.c:187
#3  0x000d7eec in imap_read_headers (idata=0x1143b60, msgbegin=14, msgend=15) 
at message.c:248
#4  0x000dbeac in imap_cmd_finish (idata=0x1143b60) at command.c:282
#5  0x000d3bfc in imap_check_mailbox (ctx=0x11074e0, index_hint=0xbfffea6c, 
force=0) at imap.c:1373
#6  0x000668ac in mx_check_mailbox (ctx=0x11074e0, index_hint=0xbfffea6c, 
lock=0) at mx.c:1366
#7  0x00025afc in mutt_index_menu () at curs_main.c:608
#8  0x00054b58 in main (argc=1, argv=0xbffff478) at main.c:966
(gdb) p h
$1 = (HEADER *) 0x0
(gdb) p i
$2 = 16
(gdb) p idata->ctx->msgcount
$3 = 17

The code right around there looks like this:

for (i = 0; i < idata->ctx->msgcount; i++)
 {
   h = idata->ctx->hdrs[i];

   if (h->index == -1)

I think a patch like this would work:

--- imap.c      2006-01-17 11:11:56.000000000 -0500
+++ imap-flea.c 2006-02-09 14:37:16.000000000 -0500
@@ -252,7 +252,7 @@
  {
    h = idata->ctx->hdrs[i];
-    if (h->index == -1)
+    if (h && h->index == -1)
    {
      dprint (2, (debugfile, "Expunging message UID %d.\n", HEADER_DATA 
(h)->uid));

But, as is noted in bug #2175, perhaps msgcount MUST always be correct?

~Kyle
--
Racism is man's greatest threat to man---the maximum of hatred for a minimum of reason.
                                              -- Abraham Joshua Heschel

Attachment: pgpAnvB59lX4g.pgp
Description: PGP signature