catch server's failure to FETCH *

the query is untypical enough to have caused problems with davmail (when
we still used *:*) and mailo.com (until it got fixed), so better check
that the result (not) returned by the server makes sense.
This commit is contained in:
Oswald Buddenhagen 2019-11-23 13:51:20 +01:00
parent dfa8c16f27
commit 94022a6752

View File

@ -2404,9 +2404,15 @@ imap_open_box_p3( imap_store_t *ctx, imap_cmd_t *gcmd, int response )
{ {
imap_cmd_open_box_t *cmdp = (imap_cmd_open_box_t *)gcmd; imap_cmd_open_box_t *cmdp = (imap_cmd_open_box_t *)gcmd;
// This will happen if the box is empty. if (!ctx->uidnext) {
if (!ctx->uidnext) if (ctx->total_msgs) {
error( "IMAP error: querying server for highest UID failed\n" );
imap_open_box_p4( ctx, cmdp, RESP_NO );
return;
}
// This is ok, the box is simply empty.
ctx->uidnext = 1; ctx->uidnext = 1;
}
imap_open_box_p4( ctx, cmdp, response ); imap_open_box_p4( ctx, cmdp, response );
} }
@ -2983,10 +2989,16 @@ imap_find_new_msgs_p3( imap_store_t *ctx, imap_cmd_t *gcmd, int response )
imap_cmd_find_new_t *cmdp = (imap_cmd_find_new_t *)gcmd; imap_cmd_find_new_t *cmdp = (imap_cmd_find_new_t *)gcmd;
imap_cmd_find_new_t *cmd; imap_cmd_find_new_t *cmd;
if (response != RESP_OK || ctx->uidnext <= cmdp->uid) { if (response != RESP_OK) {
imap_find_new_msgs_p4( ctx, gcmd, response ); imap_find_new_msgs_p4( ctx, gcmd, response );
return; return;
} }
if (!ctx->uidnext) {
// We are assuming that the new messages were not in fact instantly deleted.
error( "IMAP error: re-querying server for highest UID failed\n" );
imap_find_new_msgs_p4( ctx, gcmd, RESP_NO );
return;
}
INIT_IMAP_CMD(imap_cmd_find_new_t, cmd, cmdp->callback, cmdp->callback_aux) INIT_IMAP_CMD(imap_cmd_find_new_t, cmd, cmdp->callback, cmdp->callback_aux)
cmd->out_msgs = cmdp->out_msgs; cmd->out_msgs = cmdp->out_msgs;
imap_exec( (imap_store_t *)ctx, &cmd->gen, imap_find_new_msgs_p4, imap_exec( (imap_store_t *)ctx, &cmd->gen, imap_find_new_msgs_p4,