]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap: imap-sync - Avoid unsigned integer overflow
authorAki Tuomi <aki.tuomi@open-xchange.com>
Thu, 20 Aug 2020 06:53:11 +0000 (09:53 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 11 Sep 2020 07:07:20 +0000 (07:07 +0000)
Error: imap-sync.c:433:17: runtime error: unsigned integer overflow:
4294967295 + 1 cannot be represented in type 'unsigned int'

src/imap/imap-sync.c

index c777b941f9e28addb3f9b22a529fe5f273e4b684..ecbc83c35ab21353f92dfee2c43864fb91810634 100644 (file)
@@ -427,10 +427,10 @@ static void imap_sync_vanished(struct imap_sync_context *ctx)
        line = t_str_new(256);
        str_append(line, "* VANISHED ");
        for (i = 0; i < count; i++) {
-               start_uid = 0; prev_uid = (uint32_t)-1;
+               start_uid = 0; prev_uid = 0;
                for (seq = seqs[i].seq1; seq <= seqs[i].seq2; seq++) {
                        mail_set_seq(ctx->mail, seq);
-                       if (prev_uid + 1 != ctx->mail->uid) {
+                       if (prev_uid != ctx->mail->uid - 1) {
                                if (start_uid != 0) {
                                        if (!comma)
                                                comma = TRUE;