dovecot-2.0: dbox: Don't allow unlimited buffer size when readin...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Aug 12 20:47:05 EEST 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/ae4a82ced01e
changeset: 11993:ae4a82ced01e
user: Timo Sirainen <tss at iki.fi>
date: Thu Aug 12 18:47:01 2010 +0100
description:
dbox: Don't allow unlimited buffer size when reading message body.
diffstat:
src/lib-storage/index/dbox-common/dbox-file.c | 10 +++++++++-
src/lib-storage/index/dbox-common/dbox-mail.c | 1 +
2 files changed, 10 insertions(+), 1 deletions(-)
diffs (72 lines):
diff -r 136ce9b2e039 -r ae4a82ced01e src/lib-storage/index/dbox-common/dbox-file.c
--- a/src/lib-storage/index/dbox-common/dbox-file.c Thu Aug 12 18:45:52 2010 +0100
+++ b/src/lib-storage/index/dbox-common/dbox-file.c Thu Aug 12 18:47:01 2010 +0100
@@ -210,7 +210,7 @@
}
}
- file->input = i_stream_create_fd(file->fd, 0, FALSE);
+ file->input = i_stream_create_fd(file->fd, DBOX_READ_BLOCK_SIZE, FALSE);
i_stream_set_name(file->input, file->cur_path);
i_stream_set_init_buffer_size(file->input, DBOX_READ_BLOCK_SIZE);
return dbox_file_read_header(file);
@@ -405,6 +405,7 @@
dbox_file_seek_next_at_metadata(struct dbox_file *file, uoff_t *offset)
{
const char *line;
+ size_t buf_size;
int ret;
i_stream_seek(file->input, *offset);
@@ -412,12 +413,15 @@
return ret;
/* skip over the actual metadata */
+ buf_size = i_stream_get_max_buffer_size(file->input);
+ i_stream_set_max_buffer_size(file->input, 0);
while ((line = i_stream_read_next_line(file->input)) != NULL) {
if (*line == DBOX_METADATA_OLDV1_SPACE || *line == '\0') {
/* end of metadata */
break;
}
}
+ i_stream_set_max_buffer_size(file->input, buf_size);
*offset = file->input->v_offset;
return 1;
}
@@ -626,6 +630,7 @@
dbox_file_metadata_read_at(struct dbox_file *file, uoff_t metadata_offset)
{
const char *line;
+ size_t buf_size;
int ret;
if (file->metadata_pool != NULL)
@@ -641,6 +646,8 @@
return ret;
ret = 0;
+ buf_size = i_stream_get_max_buffer_size(file->input);
+ i_stream_set_max_buffer_size(file->input, 0);
while ((line = i_stream_read_next_line(file->input)) != NULL) {
if (*line == DBOX_METADATA_OLDV1_SPACE || *line == '\0') {
/* end of metadata */
@@ -650,6 +657,7 @@
line = p_strdup(file->metadata_pool, line);
array_append(&file->metadata, &line, 1);
}
+ i_stream_set_max_buffer_size(file->input, buf_size);
if (ret == 0)
dbox_file_set_corrupted(file, "missing end-of-metadata line");
return ret;
diff -r 136ce9b2e039 -r ae4a82ced01e src/lib-storage/index/dbox-common/dbox-mail.c
--- a/src/lib-storage/index/dbox-common/dbox-mail.c Thu Aug 12 18:45:52 2010 +0100
+++ b/src/lib-storage/index/dbox-common/dbox-mail.c Thu Aug 12 18:47:01 2010 +0100
@@ -239,6 +239,7 @@
return -1;
}
data->stream = input;
+ index_mail_set_read_buffer_size(_mail, input);
}
return index_mail_init_stream(&mail->imail, hdr_size, body_size,
More information about the dovecot-cvs
mailing list