]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
doveadm dump: Fix dumping "vsize" header in dovecot.index
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 13 Jun 2018 17:09:32 +0000 (20:09 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 22 Aug 2018 09:47:51 +0000 (12:47 +0300)
It was trying to print it as the "vsize" header in dovecot.list.index.
This caused confusing output, as well as potentially accessing memory
out of bounds.

src/doveadm/doveadm-dump-index.c

index 58a1b3e372876bbe03f5f2774182a9e741662796..c8277debf5a2d553634fd9c06dd565a425b7ef94 100644 (file)
@@ -715,7 +715,10 @@ static void dump_record(struct mail_index_view *view, unsigned int seq)
                        printf("                   : unseen   = %u\n", lrec->unseen);
                        printf("                   : recent   = %u\n", lrec->recent);
                        printf("                   : uidnext  = %u\n", lrec->uidnext);
-               } else if (strcmp(ext[i].name, "vsize") == 0) {
+               } else if (strcmp(ext[i].name, "vsize") == 0 &&
+                          ext[i].record_size >= sizeof(struct mailbox_index_vsize)) {
+                       /* this is "vsize" in dovecot.list.index, not the
+                          32bit "vsize" in dovecot.index */
                        const struct mailbox_index_vsize *vrec = data;
                        printf("                   : vsize         = %"PRIu64"\n", vrec->vsize);
                        printf("                   : highest_uid   = %u\n", vrec->highest_uid);