[dovecot-cvs] dovecot/src/lib-index mail-cache-fields.c, 1.21.2.1, 1.21.2.2
tss at dovecot.org
tss at dovecot.org
Fri Oct 13 16:19:10 UTC 2006
- Previous message: [dovecot-cvs] dovecot/src/lib-index Makefile.am, 1.27, 1.28 mail-cache-fields.c, 1.22, 1.23
- Next message: [dovecot-cvs] dovecot/src/lib-index mail-cache-lookup.c, 1.34, 1.35 mail-cache-private.h, 1.31, 1.32 mail-cache.c, 1.86, 1.87
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /var/lib/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv17911
Modified Files:
Tag: branch_1_0
mail-cache-fields.c
Log Message:
When registering fields, if they were already exited in the cache file mark
the cache file corrupted.
Index: mail-cache-fields.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-cache-fields.c,v
retrieving revision 1.21.2.1
retrieving revision 1.21.2.2
diff -u -d -r1.21.2.1 -r1.21.2.2
--- mail-cache-fields.c 11 Jun 2006 11:26:29 -0000 1.21.2.1
+++ mail-cache-fields.c 13 Oct 2006 15:18:38 -0000 1.21.2.2
@@ -11,6 +11,40 @@
#define CACHE_HDR_PREFETCH 1024
+static bool field_has_fixed_size(enum mail_cache_field_type type)
+{
+ switch (type) {
+ case MAIL_CACHE_FIELD_FIXED_SIZE:
+ case MAIL_CACHE_FIELD_BITMASK:
+ return TRUE;
+ case MAIL_CACHE_FIELD_VARIABLE_SIZE:
+ case MAIL_CACHE_FIELD_STRING:
+ case MAIL_CACHE_FIELD_HEADER:
+ return FALSE;
+ }
+
+ i_unreached();
+ return FALSE;
+}
+
+static int field_type_verify(struct mail_cache *cache, unsigned int idx,
+ enum mail_cache_field_type type, unsigned int size)
+{
+ const struct mail_cache_field *field = &cache->fields[idx].field;
+
+ if (field->type != type) {
+ mail_cache_set_corrupted(cache,
+ "registered field %s type changed", field->name);
+ return -1;
+ }
+ if (field->field_size != size && field_has_fixed_size(type)) {
+ mail_cache_set_corrupted(cache,
+ "registered field %s size changed", field->name);
+ return -1;
+ }
+ return 0;
+}
+
void mail_cache_register_fields(struct mail_cache *cache,
struct mail_cache_field *fields,
unsigned int fields_count)
@@ -26,6 +60,9 @@
&orig_key, &orig_value)) {
fields[i].idx =
POINTER_CAST_TO(orig_value, unsigned int);
+ (void)field_type_verify(cache, fields[i].idx,
+ fields[i].type,
+ fields[i].field_size);
continue;
}
@@ -66,16 +103,8 @@
cache->fields[idx].field.name = name;
cache->field_file_map[idx] = (uint32_t)-1;
- switch (cache->fields[idx].field.type) {
- case MAIL_CACHE_FIELD_FIXED_SIZE:
- case MAIL_CACHE_FIELD_BITMASK:
- break;
- case MAIL_CACHE_FIELD_VARIABLE_SIZE:
- case MAIL_CACHE_FIELD_STRING:
- case MAIL_CACHE_FIELD_HEADER:
+ if (!field_has_fixed_size(cache->fields[idx].field.type))
cache->fields[idx].field.field_size = (unsigned int)-1;
- break;
- }
hash_insert(cache->field_name_hash, name, POINTER_CAST(idx));
}
@@ -242,19 +271,9 @@
cache->fields[field.idx].field.decision =
decisions[i];
}
- if (cache->fields[field.idx].field.type != types[i]) {
- mail_cache_set_corrupted(cache,
- "registered field %s type changed",
- names);
- return -1;
- }
- if (cache->fields[field.idx].field.field_size !=
- sizes[i]) {
- mail_cache_set_corrupted(cache,
- "registered field %s size changed",
- names);
+ if (field_type_verify(cache, field.idx,
+ types[i], sizes[i]) < 0)
return -1;
- }
} else {
field.name = names;
field.type = types[i];
- Previous message: [dovecot-cvs] dovecot/src/lib-index Makefile.am, 1.27, 1.28 mail-cache-fields.c, 1.22, 1.23
- Next message: [dovecot-cvs] dovecot/src/lib-index mail-cache-lookup.c, 1.34, 1.35 mail-cache-private.h, 1.31, 1.32 mail-cache.c, 1.86, 1.87
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list