c87440b0c7
Bug #3757 - don't segfault on mailbox close with no user
37 lines
1.4 KiB
Plaintext
37 lines
1.4 KiB
Plaintext
$OpenBSD: patch-imap_statuscache_db_c,v 1.1 2012/12/10 15:25:06 ajacoutot Exp $
|
|
|
|
From 1661683d453ea444aae5832b4a2cb7fd54489672 Mon Sep 17 00:00:00 2001
|
|
From: Bron Gondwana <brong@opera.com>
|
|
Date: Sun, 09 Dec 2012 19:42:17 +0000
|
|
Subject: Bug #3757 - don't segfault on mailbox close with no user
|
|
|
|
--- imap/statuscache_db.c.orig Sat Dec 1 20:57:54 2012
|
|
+++ imap/statuscache_db.c Mon Dec 10 16:20:33 2012
|
|
@@ -150,9 +150,11 @@ static char *statuscache_buildkey(const char *mailboxn
|
|
|
|
/* 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, struc
|
|
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)",
|