Browse Source

backport: deal with UIDVALIDITY of 0 properly.

CCMAIL: skinner@destiny-denied.co.uk
-REF: 20080822094543.GA3528@ugly.local
wip/ssl-fprint
Oswald Buddenhagen 17 years ago
parent
commit
d47cca7dd9
  1. 9
      src/drv_imap.c
  2. 11
      src/sync.c

9
src/drv_imap.c

@ -817,7 +817,7 @@ static int
parse_response_code( imap_store_t *ctx, struct imap_cmd_cb *cb, char *s )
{
imap_t *imap = ctx->imap;
char *arg, *p;
char *arg, *earg, *p;
if (*s != '[')
return RESP_OK; /* no response code */
@ -829,7 +829,9 @@ parse_response_code( imap_store_t *ctx, struct imap_cmd_cb *cb, char *s )
*p++ = 0;
arg = next_arg( &s );
if (!strcmp( "UIDVALIDITY", arg )) {
if (!(arg = next_arg( &s )) || !(ctx->gen.uidvalidity = atoi( arg ))) {
if (!(arg = next_arg( &s )) ||
(ctx->gen.uidvalidity = strtoll( arg, &earg, 10 ), *earg))
{
fprintf( stderr, "IMAP error: malformed UIDVALIDITY status\n" );
return RESP_BAD;
}
@ -847,7 +849,8 @@ parse_response_code( imap_store_t *ctx, struct imap_cmd_cb *cb, char *s )
for (; isspace( (unsigned char)*p ); p++);
fprintf( stderr, "*** IMAP ALERT *** %s\n", p );
} else if (cb && cb->ctx && !strcmp( "APPENDUID", arg )) {
if (!(arg = next_arg( &s )) || !(ctx->gen.uidvalidity = atoi( arg )) ||
if (!(arg = next_arg( &s )) ||
(ctx->gen.uidvalidity = strtoll( arg, &earg, 10 ), *earg) ||
!(arg = next_arg( &s )) || !(*(int *)cb->ctx = atoi( arg )))
{
fprintf( stderr, "IMAP error: malformed APPENDUID status\n" );

11
src/sync.c

@ -474,7 +474,7 @@ sync_boxes( store_t *mctx, const char *mname,
nmmsg = nsmsg = 0;
mctx->uidvalidity = sctx->uidvalidity = 0;
mctx->uidvalidity = sctx->uidvalidity = -1;
mopts = sopts = 0;
makeopts( chan->sops, chan->slave, &sopts, chan->master, &mopts );
makeopts( chan->mops, chan->master, &mopts, chan->slave, &sopts );
@ -510,7 +510,8 @@ sync_boxes( store_t *mctx, const char *mname,
nfasprintf( &jname, "%s.journal", dname );
nfasprintf( &nname, "%s.new", dname );
nfasprintf( &lname, "%s.lock", dname );
muidval = suidval = smaxxuid = mmaxuid = smaxuid = 0;
muidval = suidval = -1;
smaxxuid = mmaxuid = smaxuid = 0;
memset( &lck, 0, sizeof(lck) );
#if SEEK_SET != 0
lck.l_whence = SEEK_SET;
@ -705,7 +706,7 @@ sync_boxes( store_t *mctx, const char *mname,
info( "%d messages, %d recent\n", sctx->count, sctx->recent );
dump_box( sctx );
if (suidval && suidval != sctx->uidvalidity) {
if (suidval >= 0 && suidval != sctx->uidvalidity) {
fprintf( stderr, "Error: UIDVALIDITY of slave changed\n" );
ret = SYNC_FAIL;
goto bail;
@ -809,13 +810,13 @@ sync_boxes( store_t *mctx, const char *mname,
info( "%d messages, %d recent\n", mctx->count, mctx->recent );
dump_box( mctx );
if (muidval && muidval != mctx->uidvalidity) {
if (muidval >= 0 && muidval != mctx->uidvalidity) {
fprintf( stderr, "Error: UIDVALIDITY of master changed\n" );
ret = SYNC_FAIL;
goto finish;
}
if (!muidval || !suidval) {
if (muidval < 0 || suidval < 0) {
muidval = mctx->uidvalidity;
suidval = sctx->uidvalidity;
Fprintf( jfp, "| %d %d\n", muidval, suidval );

Loading…
Cancel
Save