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

@ -50,6 +50,7 @@
#include "mu-maildir.h"
#include "mu-query.h"
#include "mu-index.h"
#include "mu-store.h"
#include "mu-msg-part.h"
#include "mu-contacts.h"
@ -275,6 +276,13 @@ get_docids_from_msgids (MuQuery *query, const char *msgid,
MuMsgIter *iter;
GSList *lst;
if (!msgid || strlen(msgid) > MU_STORE_MAX_TERM_LENGTH - 1) {
mu_util_g_set_error (err, MU_ERROR_IN_PARAMETERS,
"invalid message-id '%s' (length=%zu)",
msgid, strlen(msgid));
return NULL;
}
xprefix = mu_msg_field_xapian_prefix(MU_MSG_FIELD_ID_MSGID);
/*XXX this is a bit dodgy */
tmp = g_ascii_strdown(msgid, -1);