isync

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

commit 3d5539bb63b7f494f20357d7491d96228a432600
parent 8513358e0a3f3d720b394251a018e46ed87ef262
Author: Oswald Buddenhagen <ossi@users.sf.net>
Date:   Sat, 28 Jun 2014 11:58:26 +0200

detect inconsistent state of highest assigned UID

the highest assigned UID must always be at least as high as the highest
actually found UID, as otherwise we'd hand out duplicate UIDs at some
point. also, getting into such a state in the first place indicates some
potentially serious trouble, or at least external interference (e.g.,
moving/copying a message from another folder without giving it a
pristine filename).

REFMAIL: 20140626211831.GA11590@sie.protva.ru

Diffstat:
Msrc/drv_maildir.c | 7+++++++
1 file changed, 7 insertions(+), 0 deletions(-)

diff --git a/src/drv_maildir.c b/src/drv_maildir.c @@ -787,6 +787,13 @@ maildir_scan( maildir_store_t *ctx, msglist_t *msglist ) #endif } uid = entry->uid; + if (uid > ctx->nuid) { + /* In principle, we could just warn and top up nuid. However, getting into this + * situation might indicate some serious trouble, so let's not make it worse. */ + error( "Maildir error: UID %d is beyond highest assigned UID %d.\n", uid, ctx->nuid ); + maildir_free_scan( msglist ); + return DRV_BOX_BAD; + } if ((ctx->gen.opts & OPEN_SIZE) || ((ctx->gen.opts & OPEN_FIND) && uid >= ctx->newuid)) nfsnprintf( buf + bl, sizeof(buf) - bl, "%s/%s", subdirs[entry->recent], entry->base ); #ifdef USE_DB