[dovecot-cvs] dovecot/src/lib-index mail-cache-compress.c, 1.21,
1.22
cras at dovecot.org
cras at dovecot.org
Thu Oct 7 23:36:51 EEST 2004
Update of /var/lib/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv13464/lib-index
Modified Files:
mail-cache-compress.c
Log Message:
Added asserts
Index: mail-cache-compress.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-cache-compress.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- mail-cache-compress.c 26 Sep 2004 14:15:54 -0000 1.21
+++ mail-cache-compress.c 7 Oct 2004 20:36:48 -0000 1.22
@@ -25,6 +25,7 @@
for (pos = sizeof(struct mail_cache_record); pos < buf_size; ) {
buf_field = *((uint32_t *)PTR_OFFSET(buf_data, pos));
pos += sizeof(uint32_t);
+ i_assert(buf_field < cache->fields_count);
buf_data_size = cache->fields[buf_field].field.field_size;
if (buf_data_size == (unsigned int)-1) {
@@ -34,15 +35,17 @@
}
if (buf_field == field) {
- /* found it, do the merging */
+ /* @UNSAFE: found it, do the merging */
unsigned char *dest = PTR_OFFSET(buf_data, pos);
i_assert(buf_data_size == data_size);
+ i_assert(pos + buf_data_size <= buf_size);
for (i = 0; i < buf_data_size; i++)
dest[i] |= ((const unsigned char*)data)[i];
break;
}
pos += (data_size + 3) & ~3;
+ i_assert(pos <= buf_size);
}
}
More information about the dovecot-cvs
mailing list