commit 3febb16fd5567ed18acd829a702193f97c9d30d3
Author: Oswald Buddenhagen <o...@users.sf.net>
Date:   Mon Feb 21 10:07:00 2022 +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.

 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 3cefa739..18c3cac1 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 40713d4e..2625c74f 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


_______________________________________________
isync-devel mailing list
isync-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/isync-devel

Reply via email to