Squatter crash with statusdb

Simon Matter simon.matter at invoca.ch
Mon Jun 24 08:24:16 EDT 2013


> Hi Andy, could you file a bug for this?  Then it will not be forgotten...

Or, could you check this bug here
http://bugzilla.cyrusimap.org/show_bug.cgi?id=3757

The patch below was the fix, could you verify if it also fixes your issue?

Thanks,
Simon

>From 1661683d453ea444aae5832b4a2cb7fd54489672 Mon Sep 17 00:00:00 2001
From: Bron Gondwana <brong at opera.com>
Date: Sun, 09 Dec 2012 19:42:17 +0000
Subject: Bug #3757 - don't segfault on mailbox close with no user

Broke squatter and possibly other users as well.

This is probably a 2.4 only fix - the code has changed
for statuscache a bit since.
---
diff --git a/imap/statuscache_db.c b/imap/statuscache_db.c
index fadc58d..41dfd2b 100644
--- a/imap/statuscache_db.c
+++ b/imap/statuscache_db.c
@@ -150,9 +150,11 @@ static char *statuscache_buildkey(const char
*mailboxname, const char *userid,

     /* Build statuscache key */
     len = strlcpy(key, mailboxname, sizeof(key));
+    /* double % is a safe separator, it can't exist in a mailboxname */
     key[len++] = '%';
     key[len++] = '%';
-    len += strlcpy(key + len, userid, sizeof(key) - len);
+    if (userid)
+       len += strlcpy(key + len, userid, sizeof(key) - len);

     *keylen = len;

@@ -410,11 +412,9 @@ int statuscache_invalidate(const char *mboxname,
struct statusdata *sdata)
     drock.db = statuscachedb;
     drock.tid = NULL;

-    key = statuscache_buildkey(mboxname, "", &keylen);
+    key = statuscache_buildkey(mboxname, /*userid*/NULL, &keylen);

-    /* strip off the second NULL that buildkey added, so we match
-     * the entires for all users */
-    r = DB->foreach(drock.db, key, keylen - 1, NULL, delete_cb,
+    r = DB->foreach(drock.db, key, keylen, NULL, delete_cb,
                    &drock, &drock.tid);
     if (r != CYRUSDB_OK) {
        syslog(LOG_ERR, "DBERROR: error invalidating: %s (%s)",


>
> Quoting Andy Fiddaman <cyrus at fiddaman.net>, Mon, 24 Jun 2013:
>
>> FWIW, this gets it working again:
>>
>> --- cyrus-imapd-2.4.17.dist/imap/statuscache_db.c       2013-06-24
>> 10:10:08.219203100 +0000
>> +++ cyrus-imapd-2.4.17/imap/statuscache_db.c    2013-06-24
>> 10:10:20.537711377 +0000
>> @@ -152,7 +152,7 @@
>>      len = strlcpy(key, mailboxname, sizeof(key));
>>      key[len++] = '%';
>>      key[len++] = '%';
>> -    len += strlcpy(key + len, userid, sizeof(key) - len);
>> +    len += strlcpy(key + len, userid ? userid : "cyrus", sizeof(key) -
>> len);
>>
>>      *keylen = len;
>>
>>
>> On Mon, 24 Jun 2013, Andy Fiddaman wrote:
>>
>> ;
>> ; Hi,
>> ;
>> ; I've just upgraded my Cyrus installation to 2.4.17 and squatter is
>> ; crashing in statuscache_buildkey() because userid is NULL.
>> ;
>> ; I'm not sure what the best fix for this is. Should squatter even be
>> using
>> ; the statuscache or should it populate "cyrus" as the username when
>> ; initialising the index, or something else?
>> ;
>> ; Thanks,
>> ;
>> ; Andy
>> ;
>> ; Program received signal SIGSEGV, Segmentation fault.
>> ; [Switching to Thread 1 (LWP 1)]
>> ; 0xfffffd7ffe3dccb0 in .strlenalign16_loop () from /lib/64/libc.so.1
>> ; (gdb) where
>> ; #0  0xfffffd7ffe3dccb0 in .strlenalign16_loop () from
>> /lib/64/libc.so.1
>> ; #1  0xfffffd7ffe414149 in strlcpy () from /lib/64/libc.so.1
>> ; #2  0x00000000004610ac in statuscache_buildkey (
>> ;     mailboxname=0x5ab8b0 "example.net!user.silo", userid=0x0,
>> ;     keylen=0xfffffd7fffdfe0cc) at statuscache_db.c:155
>> ; #3  0x000000000046169a in statuscache_update_txn (
>> ;     mboxname=0x5ab8b0 "example.net!user.silo",
>> sdata=0xfffffd7fffdfe290,
>> ;     tidptr=0xfffffd7fffdfe218) at statuscache_db.c:326
>> ; #4  0x00000000004619ad in statuscache_invalidate (
>> ;     mboxname=0x5ab8b0 "example.net!user.silo",
>> sdata=0xfffffd7fffdfe290)
>> ;     at statuscache_db.c:425
>> ; #5  0x0000000000434099 in mailbox_unlock_index (mailbox=0x5db998,
>> ;     sdata=0xfffffd7fffdfe290) at mailbox.c:1637
>> ; #6  0x0000000000422feb in index_unlock (state=0x5af6a0) at
>> index.c:1232
>> ; #7  0x0000000000420c98 in index_open (name=0x5ac960
>> ; "example.net!user.silo",
>> ;     init=0x0, stateptr=0xfffffd7fffdfec18) at index.c:246
>> ; #8  0x0000000000420395 in index_me (name=0x5ac960
>> "example.net!user.silo",
>> ;     matchlen=20, maycreate=0, rock=0xfffffd7fffdffcac) at
>> squatter.c:594
>> ; #9  0x00000000004208f9 in main (argc=3, argv=0xfffffd7fffdffcf8)
>> ;     at squatter.c:745
>> ;
>> ;
>> ; (gdb) frame 7
>> ; #7  0x0000000000420c98 in index_open (name=0x5ac960
>> ; "example.net!user.silo",
>> ;     init=0x0, stateptr=0xfffffd7fffdfec18) at index.c:246
>> ; 246     in index.c
>> ; (gdb) print *state
>> ; $4 = {mailbox = 0x5db998, num_records = 6933, oldexists = 0, exists =
>> ; 6933,
>> ;   last_uid = 6934, highestmodseq = 1606, delayed_modseq = 0, map =
>> ; 0x5dd740,
>> ;   mapsize = 7168, internalseen = 0, skipped_expunge = 0, seen_dirty =
>> 0,
>> ;   keepingseen = 0, examining = 0, myrights = 0, numrecent = 0,
>> ;   numunseen = 6933, firstnotseen = 1, flagname = {0x0 <repeats 128
>> ; times>},
>> ;   userid = 0x0, out = 0x0, qresync = 0, authstate = 0x0}
>> ;
>> ; ----
>> ; Cyrus Home Page: http://www.cyrusimap.org/
>> ; List Archives/Info: http://lists.andrew.cmu.edu/pipermail/info-cyrus/
>> ; To Unsubscribe:
>> ; https://lists.andrew.cmu.edu/mailman/listinfo/info-cyrus
>> ;
>> ----
>> Cyrus Home Page: http://www.cyrusimap.org/
>> List Archives/Info: http://lists.andrew.cmu.edu/pipermail/info-cyrus/
>> To Unsubscribe:
>> https://lists.andrew.cmu.edu/mailman/listinfo/info-cyrus
>
> --
>   -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
>   Rudy Gevaert                             e-mail: Rudy.Gevaert at UGent.be
>   Directie ICT, Afdeling Infrastructuur
>   Groep Systemen                                      tel: +32 9 264 4750
>   Universiteit Gent                                   fax: +32 9 264 4994
>   Krijgslaan 281, gebouw S9, 9000 Gent, Belgie               www.UGent.be
>   -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
>
>
> ----
> Cyrus Home Page: http://www.cyrusimap.org/
> List Archives/Info: http://lists.andrew.cmu.edu/pipermail/info-cyrus/
> To Unsubscribe:
> https://lists.andrew.cmu.edu/mailman/listinfo/info-cyrus
>




More information about the Info-cyrus mailing list