From 3febb16fd5567ed18acd829a702193f97c9d30d3 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 21 Feb 2022 10:07:00 +0100 Subject: [PATCH] fix off-by-one when loading messages outside the bulk range this would lead to a bogus deletion being propagated to the near side. --- src/run-tests.pl | 22 ++++++++++++++++++++++ src/sync.c | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/run-tests.pl b/src/run-tests.pl index 3cefa73..18c3cac 100755 --- a/src/run-tests.pl +++ b/src/run-tests.pl @@ -1246,6 +1246,28 @@ my @X34 = ( ); test("max messages + expire - new", \@x33, \@X34, \@O34); +my @x35 = ( + B, 0, B, + A, "*F", "*F", "*F", + B, "*", "*", "*", + C, "*", "", "", + D, "*", "", "", + E, "*", "", "", + F, "*", "", "", + G, "*", "", "", + H, "*", "", "", +); + +my @O35 = ("", "", "Sync New\nMaxMessages 3\nExpireUnread yes\n"); +my @X35 = ( + H, E, H, + B, "", "+~", "+T", + F, "", "*", "*", + G, "", "*", "*", + H, "", "*", "*", +); +test("max messages + expire - too many new", \@x35, \@X35, \@O35); + my @x38 = ( F, C, 0, A, "*FS", "*FS", "*S", diff --git a/src/sync.c b/src/sync.c index 40713d4..2625c74 100644 --- a/src/sync.c +++ b/src/sync.c @@ -813,7 +813,7 @@ box_opened2( sync_vars_t *svars, int t ) continue; // No message; other state is irrelevant if (srec->uid[F] >= minwuid) continue; // Message is in non-expired range - if ((svars->opts[F] & OPEN_NEW) && srec->uid[F] >= svars->maxuid[F]) + if ((svars->opts[F] & OPEN_NEW) && srec->uid[F] > svars->maxuid[F]) continue; // Message is in expired range, but new range overlaps that if (!srec->uid[N] && !(srec->status & S_PENDING)) continue; // Only actually paired up messages matter