dovecot-1.1: MAIL_FETCH_UIDL_BACKEND crashed with non-maildir ba...
dovecot at dovecot.org
dovecot at dovecot.org
Sat May 31 13:47:15 EEST 2008
details: http://hg.dovecot.org/dovecot-1.1/rev/8e7a15987428
changeset: 7582:8e7a15987428
user: Timo Sirainen <tss at iki.fi>
date: Sat May 31 13:47:11 2008 +0300
description:
MAIL_FETCH_UIDL_BACKEND crashed with non-maildir backends. Changed the API a
bit and fixed/cleaned/optimized POP3 UIDL listing a bit.
diffstat:
3 files changed, 48 insertions(+), 40 deletions(-)
src/lib-storage/index/index-mail.c | 1
src/lib-storage/index/maildir/maildir-mail.c | 8 --
src/pop3/commands.c | 79 ++++++++++++++------------
diffs (135 lines):
diff -r 89041c61c10b -r 8e7a15987428 src/lib-storage/index/index-mail.c
--- a/src/lib-storage/index/index-mail.c Fri May 30 22:55:46 2008 +0300
+++ b/src/lib-storage/index/index-mail.c Sat May 31 13:47:11 2008 +0300
@@ -991,6 +991,7 @@ int index_mail_get_special(struct mail *
return 0;
case MAIL_FETCH_FROM_ENVELOPE:
case MAIL_FETCH_UIDL_FILE_NAME:
+ case MAIL_FETCH_UIDL_BACKEND:
*value_r = "";
return 0;
case MAIL_FETCH_HEADER_MD5:
diff -r 89041c61c10b -r 8e7a15987428 src/lib-storage/index/maildir/maildir-mail.c
--- a/src/lib-storage/index/maildir/maildir-mail.c Fri May 30 22:55:46 2008 +0300
+++ b/src/lib-storage/index/maildir/maildir-mail.c Sat May 31 13:47:11 2008 +0300
@@ -430,12 +430,8 @@ maildir_mail_get_special(struct mail *_m
} else if (field == MAIL_FETCH_UIDL_BACKEND) {
uidl = maildir_uidlist_lookup_ext(mbox->uidlist, _mail->uid,
MAILDIR_UIDLIST_REC_EXT_POP3_UIDL);
- if (uidl != NULL) {
- *value_r = uidl;
- return 0;
- } else {
- return -1;
- }
+ *value_r = uidl != NULL ? uidl : "";
+ return 0;
}
return index_mail_get_special(_mail, field, value_r);
diff -r 89041c61c10b -r 8e7a15987428 src/pop3/commands.c
--- a/src/pop3/commands.c Fri May 30 22:55:46 2008 +0300
+++ b/src/pop3/commands.c Sat May 31 13:47:11 2008 +0300
@@ -506,6 +506,49 @@ struct cmd_uidl_context {
struct mail_search_seqset seqset;
};
+static void pop3_get_uid(struct cmd_uidl_context *ctx,
+ struct var_expand_table *tab, string_t *str)
+{
+ char uid_str[MAX_INT_STRLEN];
+ const char *uidl;
+
+ if (mail_get_special(ctx->mail, MAIL_FETCH_UIDL_BACKEND, &uidl) == 0 &&
+ *uidl != '\0') {
+ str_append(str, uidl);
+ return;
+ }
+
+ if (reuse_xuidl &&
+ mail_get_first_header(ctx->mail, "X-UIDL", &uidl) > 0) {
+ str_append(str, uidl);
+ return;
+ }
+
+ if ((uidl_keymask & UIDL_UID) != 0) {
+ i_snprintf(uid_str, sizeof(uid_str), "%u",
+ ctx->mail->uid);
+ tab[1].value = uid_str;
+ }
+ if ((uidl_keymask & UIDL_MD5) != 0) {
+ if (mail_get_special(ctx->mail, MAIL_FETCH_HEADER_MD5,
+ &tab[2].value) < 0 ||
+ *tab[2].value == '\0') {
+ /* broken */
+ i_fatal("UIDL: Header MD5 not found");
+ }
+ }
+ if ((uidl_keymask & UIDL_FILE_NAME) != 0) {
+ if (mail_get_special(ctx->mail,
+ MAIL_FETCH_UIDL_FILE_NAME,
+ &tab[3].value) < 0 ||
+ *tab[3].value == '\0') {
+ /* broken */
+ i_fatal("UIDL: File name not found");
+ }
+ }
+ var_expand(str, uidl_format, tab);
+}
+
static bool list_uids_iter(struct client *client, struct cmd_uidl_context *ctx)
{
static struct var_expand_table static_tab[] = {
@@ -517,8 +560,6 @@ static bool list_uids_iter(struct client
};
struct var_expand_table *tab;
string_t *str;
- char uid_str[MAX_INT_STRLEN];
- const char *uidl;
int ret;
bool found = FALSE;
@@ -536,41 +577,11 @@ static bool list_uids_iter(struct client
}
found = TRUE;
- if ((uidl_keymask & UIDL_UID) != 0) {
- i_snprintf(uid_str, sizeof(uid_str), "%u",
- ctx->mail->uid);
- tab[1].value = uid_str;
- }
- if ((uidl_keymask & UIDL_MD5) != 0) {
- if (mail_get_special(ctx->mail, MAIL_FETCH_HEADER_MD5,
- &tab[2].value) < 0 ||
- *tab[2].value == '\0') {
- /* broken */
- i_fatal("UIDL: Header MD5 not found");
- }
- }
- if ((uidl_keymask & UIDL_FILE_NAME) != 0) {
- if (mail_get_special(ctx->mail,
- MAIL_FETCH_UIDL_FILE_NAME,
- &tab[3].value) < 0 ||
- *tab[3].value == '\0') {
- /* broken */
- i_fatal("UIDL: File name not found");
- }
- }
-
str_truncate(str, 0);
str_printfa(str, ctx->message == 0 ? "%u " : "+OK %u ",
ctx->mail->seq);
-
- if (mail_get_special(ctx->mail, MAIL_FETCH_UIDL_BACKEND,
- &uidl) == 0)
- str_append(str, uidl);
- else if (reuse_xuidl &&
- mail_get_first_header(ctx->mail, "X-UIDL", &uidl) > 0)
- str_append(str, uidl);
- else
- var_expand(str, uidl_format, tab);
+ pop3_get_uid(ctx, tab, str);
+
ret = client_send_line(client, "%s", str_c(str));
if (ret < 0)
break;
More information about the dovecot-cvs
mailing list