[dovecot-cvs] dovecot/src/lib-index mail-tree.c,1.17,1.18 mail-modifylog.c,1.44,1.45 mail-index-open.c,1.29,1.30 mail-index-data.c,1.39,1.40
cras at procontrol.fi
cras at procontrol.fi
Wed Apr 23 17:23:17 EEST 2003
Update of /home/cvs/dovecot/src/lib-index
In directory danu:/tmp/cvs-serv16474
Modified Files:
mail-tree.c mail-modifylog.c mail-index-open.c
mail-index-data.c
Log Message:
Don't crash if mmap_anon() doesn't succeed.
Index: mail-tree.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-tree.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- mail-tree.c 16 Apr 2003 15:13:24 -0000 1.17
+++ mail-tree.c 23 Apr 2003 13:23:14 -0000 1.18
@@ -302,6 +302,9 @@
if (tree->anon_mmap) {
tree->mmap_full_length = MAIL_TREE_MIN_SIZE;
tree->mmap_base = mmap_anon(tree->mmap_full_length);
+ if (tree->mmap_base == MAP_FAILED)
+ return tree_set_syscall_error(tree, "mmap_anon()");
+
memcpy(tree->mmap_base, &hdr, sizeof(struct mail_tree_header));
return mmap_verify(tree);
}
Index: mail-modifylog.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-modifylog.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- mail-modifylog.c 30 Mar 2003 12:48:37 -0000 1.44
+++ mail-modifylog.c 23 Apr 2003 13:23:14 -0000 1.45
@@ -512,12 +512,15 @@
return FALSE;
}
-static void modifylog_create_anon(struct modify_log_file *file)
+static int modifylog_create_anon(struct modify_log_file *file)
{
file->mmap_full_length = MODIFY_LOG_INITIAL_SIZE;
file->mmap_base = mmap_anon(file->mmap_full_length);
file->header = file->mmap_base;
+ if (file->mmap_base == MAP_FAILED)
+ return modifylog_set_syscall_error(file, "mmap_anon()");
+
mail_modifylog_init_header(file->log, file->mmap_base);
file->mmap_used_length = file->header->used_file_size;
@@ -526,6 +529,7 @@
file->anon_mmap = TRUE;
file->filepath = i_strdup_printf("(in-memory modify log for %s)",
file->log->index->mailbox_path);
+ return TRUE;
}
int mail_modifylog_create(struct mail_index *index)
@@ -537,9 +541,12 @@
log = mail_modifylog_new(index);
- if (INDEX_IS_IN_MEMORY(index))
- modifylog_create_anon(&log->file1);
- else {
+ if (INDEX_IS_IN_MEMORY(index)) {
+ if (!modifylog_create_anon(&log->file1)) {
+ mail_modifylog_free(log);
+ return FALSE;
+ }
+ } else {
ret = modifylog_reuse_or_create_file(&log->file1);
if (ret == 0) {
index_set_error(log->index,
Index: mail-index-open.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index-open.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- mail-index-open.c 16 Apr 2003 20:26:11 -0000 1.29
+++ mail-index-open.c 23 Apr 2003 13:23:14 -0000 1.30
@@ -285,6 +285,8 @@
index->mmap_full_length = INDEX_FILE_MIN_SIZE;
index->mmap_base = mmap_anon(index->mmap_full_length);
+ if (index->mmap_base == MAP_FAILED)
+ return index_file_set_syscall_error(index, path, "mmap_anon()");
mail_index_init_header(index, index->mmap_base);
index->header = index->mmap_base;
Index: mail-index-data.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index-data.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- mail-index-data.c 12 Apr 2003 15:39:29 -0000 1.39
+++ mail-index-data.c 23 Apr 2003 13:23:14 -0000 1.40
@@ -303,6 +303,11 @@
if (fd == -1) {
data->mmap_full_length = INDEX_DATA_INITIAL_SIZE;
data->mmap_base = mmap_anon(data->mmap_full_length);
+ if (data->mmap_base == MAP_FAILED) {
+ i_free(data);
+ return index_file_set_syscall_error(index, path,
+ "mmap_anon()");
+ }
memcpy(data->mmap_base, &hdr, sizeof(hdr));
data->header = data->mmap_base;
More information about the dovecot-cvs
mailing list