commit 3febb16fd5567ed18acd829a702193f97c9d30d3
parent 0089f49c4af7abb7634408e402096423a22d0462
Author: Oswald Buddenhagen <ossi@users.sf.net>
Date: Mon, 21 Feb 2022 10:07:00 +0100
fix off-by-one when loading messages outside the bulk range
this would lead to a bogus deletion being propagated to the near side.
Diffstat:
2 files changed, 23 insertions(+), 1 deletion(-)
diff --git 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
@@ -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