summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2021-09-07 21:42:07 -0700
committerKevin McCarthy <kevin@8t8.us>2021-09-08 11:05:55 -0700
commitfa2fef4618ed45d9f4011ea76fd8bc3844d59c88 (patch)
tree88ded4f1a4eaeffa70964058c2c4999e93d81aa4
parent9a92dba0d7c4e122d46588f13e050773864fc729 (diff)
Fix compare_uid() to work with large UID values.
The function was pulled from the other sort methods used in mutt. But those don't work properly for a 32-bit unsigned value. If the difference between two UID values is greater than a signed int can represent, it will sort improperly. Some of the other sort functions need to be fixed too, but that can be done in master.
-rw-r--r--imap/imap.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/imap/imap.c b/imap/imap.c
index cc25213d..ee846f37 100644
--- a/imap/imap.c
+++ b/imap/imap.c
@@ -1134,7 +1134,11 @@ static int compare_uid (const void *a, const void *b)
HEADER **pa = (HEADER **) a;
HEADER **pb = (HEADER **) b;
- return HEADER_DATA(*pa)->uid - HEADER_DATA(*pb)->uid;
+ if (HEADER_DATA(*pa)->uid < HEADER_DATA(*pb)->uid)
+ return -1;
+ if (HEADER_DATA(*pa)->uid > HEADER_DATA(*pb)->uid)
+ return 1;
+ return 0;
}
/* Note: headers must be in SORT_UID. See imap_exec_msgset for args.