From: Timo Sirainen Date: Thu, 4 Dec 2025 11:46:03 +0000 (+0200) Subject: lib-imap: seqset - Fail if seeing over 32bit sequence numbers X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6e94fa43749ef4fe4e9d40cb1758d78d2850414b;p=thirdparty%2Fdovecot%2Fcore.git lib-imap: seqset - Fail if seeing over 32bit sequence numbers Previously they were wrapped to 32bit number. --- diff --git a/src/lib-imap/imap-seqset.c b/src/lib-imap/imap-seqset.c index d2a1f0801a..f050262b52 100644 --- a/src/lib-imap/imap-seqset.c +++ b/src/lib-imap/imap-seqset.c @@ -8,14 +8,8 @@ static uint32_t get_next_number(const char **str) { uint32_t num; - num = 0; - while (**str != '\0') { - if (**str < '0' || **str > '9') - break; - - num = num*10 + (**str - '0'); - (*str)++; - } + if (str_parse_uint32(*str, &num, str) < 0) + return 0; if (num == (uint32_t)-1) { /* FIXME: ugly hack, we're using this number to mean the diff --git a/src/lib-imap/test-imap-seqset.c b/src/lib-imap/test-imap-seqset.c index 8252144a97..e0321a77eb 100644 --- a/src/lib-imap/test-imap-seqset.c +++ b/src/lib-imap/test-imap-seqset.c @@ -55,6 +55,7 @@ static void test_imap_seq_set_parse(void) with uidsets ending with comma. */ { "1,2,", "1:2", 0 }, { "4294967296", "", -1 }, + { "4294967297", "", -1 }, { "4294967295", "4294967294", 0 }, { "4294967294:4294967295", "4294967294", 0 }, { "4294967293:4294967295", "4294967293:4294967294", 0 },