]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-imap: seqset - Fail if seeing over 32bit sequence numbers
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 4 Dec 2025 11:46:03 +0000 (13:46 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 28 Nov 2025 09:37:47 +0000 (09:37 +0000)
Previously they were wrapped to 32bit number.

src/lib-imap/imap-seqset.c
src/lib-imap/test-imap-seqset.c

index d2a1f0801a95096c1405a49b11b93e7b9adb8cb9..f050262b52a452b83d5b59cf745458a3c7c36f7b 100644 (file)
@@ -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
index 8252144a977704b0ac14a57d0aaa760c6681b409..e0321a77ebd416ab7a7be6dd19e294976d7beda9 100644 (file)
@@ -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 },