isync

mailbox synchronization program
git clone https://git.code.sf.net/p/isync/isync
Log | Files | Refs | README | LICENSE

commit 444601a1e07b8b3e74a4a20b31c71b16f3c61994
parent a86e6f8c7c9a3aebb894dc047545c8902e850e71
Author: Oswald Buddenhagen <ossi@users.sf.net>
Date:   Thu,  3 Jun 2021 11:04:56 +0200

Merge branch '1.3' into 1.4

Conflicts:
	configure.ac
	src/drv_imap.c

Diffstat:
Msrc/drv_imap.c | 19++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/drv_imap.c b/src/drv_imap.c @@ -217,7 +217,6 @@ typedef union { IMAP_CMD void (*callback)( int sts, uint uid, void *aux ); void *callback_aux; - uint out_uid; }; } imap_cmd_out_uid_t; @@ -1289,11 +1288,22 @@ parse_response_code( imap_store_t *ctx, imap_cmd_t *cmd, char *s ) } for (; isspace( (uchar)*s ); s++); error( "*** IMAP ALERT *** %s\n", s ); - } else if (cmd && !strcmp( "APPENDUID", arg )) { + } else if (!strcmp( "APPENDUID", arg )) { + // The checks ensure that: + // - cmd => this is the final tagged response of a command, at which + // point cmd was already removed from ctx->in_progress, so param.uid + // is available for reuse. + // - !param.uid => the command isn't actually a FETCH. This doesn't + // really matter, as the field is safe to overwrite given the + // previous condition; it just has no effect for non-APPENDs. + if (!cmd || cmd->param.uid) { + error( "IMAP error: unexpected APPENDUID status\n" ); + return RESP_CANCEL; + } if (!(arg = next_arg( &s )) || (ctx->uidvalidity = strtoul( arg, &earg, 10 ), *earg) || !(arg = next_arg( &s )) || - (((imap_cmd_out_uid_t *)cmd)->out_uid = strtoul( arg, &earg, 10 ), *earg != ']')) + (cmd->param.uid = strtoul( arg, &earg, 10 ), *earg != ']')) { error( "IMAP error: malformed APPENDUID status\n" ); return RESP_CANCEL; @@ -3167,7 +3177,6 @@ imap_store_msg( store_t *gctx, msg_data_t *data, int to_trash, ctx->buffer_mem += data->len; cmd->param.data_len = data->len; cmd->param.data = data->data; - cmd->out_uid = 0; if (to_trash) { cmd->param.create = 1; @@ -3203,7 +3212,7 @@ imap_store_msg_p2( imap_store_t *ctx ATTR_UNUSED, imap_cmd_t *cmd, int response imap_cmd_out_uid_t *cmdp = (imap_cmd_out_uid_t *)cmd; transform_msg_response( &response ); - cmdp->callback( response, cmdp->out_uid, cmdp->callback_aux ); + cmdp->callback( response, cmdp->param.uid, cmdp->callback_aux ); } /******************* imap_find_new_msgs *******************/