]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
fts: Improved doveadm fts dump for corrupted expunge log
authorTimo Sirainen <tss@iki.fi>
Thu, 12 Jun 2014 22:11:24 +0000 (01:11 +0300)
committerTimo Sirainen <tss@iki.fi>
Thu, 12 Jun 2014 22:11:24 +0000 (01:11 +0300)
Although we may still be trying to allocate up to 2 GB of memory, but at
least no more than that now.
Found by Coverity

src/plugins/fts/doveadm-dump-fts-expunge-log.c

index 8d4a2ae9209a12dfff1847626514f02bda47ab47..1b78769230242fea959ed741deb0f0d73182515b 100644 (file)
@@ -36,6 +36,11 @@ static int dump_record(int fd, buffer_t *buf)
        if (ret != sizeof(rec))
                i_fatal("rec read() %d != %d", (int)ret, (int)sizeof(rec));
 
+       if (rec.record_size < sizeof(rec) + sizeof(uint32_t) ||
+           rec.record_size > INT_MAX) {
+               i_fatal("Invalid record_size=%u at offset %"PRIuUOFF_T,
+                       rec.record_size, offset);
+       }
        data_size = rec.record_size - sizeof(rec);
        buffer_set_used_size(buf, 0);
        data = buffer_append_space_unsafe(buf, data_size);