mu: protect against overly long keys

We got some errors when some of the key values exceeded the Xapian
maximum; in particular the message-id.

So make all the key-methods check, and truncate the message-id if
necessary.
This commit is contained in:
djcb
2018-08-14 21:57:33 +03:00
parent a4398ac93d
commit 93c6ff1f85
6 changed files with 43 additions and 33 deletions

View File

@ -46,7 +46,6 @@ private:
const std::string _what;
};
struct _MuStore {
public:
/* create a read-write MuStore */
@ -196,7 +195,7 @@ public:
mu_store_set_metadata (this, MU_STORE_VERSION_KEY, vers, NULL);
}
static unsigned max_term_length() { return MAX_TERM_LENGTH; }
static unsigned max_term_length() { return MU_STORE_MAX_TERM_LENGTH; }
void begin_transaction ();
void commit_transaction ();
@ -237,9 +236,6 @@ public:
/* by default, use transactions of 30000 messages */
static const unsigned DEFAULT_BATCH_SIZE = 30000;
/* http://article.gmane.org/gmane.comp.search.xapian.general/3656 */
static const unsigned MAX_TERM_LENGTH = 240;
private:
/* transaction handling */
bool _in_transaction;