dovecot-2.0: dbox: Give more verbose error message about broken ...
dovecot at dovecot.org
dovecot at dovecot.org
Sat Mar 12 17:24:44 EET 2011
details: http://hg.dovecot.org/dovecot-2.0/rev/d3d6ed6d268b
changeset: 12676:d3d6ed6d268b
user: Timo Sirainen <tss at iki.fi>
date: Sat Mar 12 17:24:38 2011 +0200
description:
dbox: Give more verbose error message about broken attachment ext-refs.
diffstat:
src/lib-storage/index/dbox-common/dbox-attachment.c | 34 +++++++++++-----
1 files changed, 23 insertions(+), 11 deletions(-)
diffs (82 lines):
diff -r b896d72d7fa7 -r d3d6ed6d268b src/lib-storage/index/dbox-common/dbox-attachment.c
--- a/src/lib-storage/index/dbox-common/dbox-attachment.c Sat Mar 12 17:18:47 2011 +0200
+++ b/src/lib-storage/index/dbox-common/dbox-attachment.c Sat Mar 12 17:24:38 2011 +0200
@@ -139,7 +139,8 @@
static int
dbox_attachment_file_get_stream_from(struct dbox_file *file,
const char *ext_refs,
- struct istream **stream)
+ struct istream **stream,
+ const char **error_r)
{
ARRAY_TYPE(mail_attachment_extref) extrefs_arr;
ARRAY_DEFINE(streams, struct istream *);
@@ -150,10 +151,14 @@
unsigned int i;
int ret = 1;
+ *error_r = NULL;
+
t_array_init(&extrefs_arr, 16);
if (!dbox_attachment_parse_extref_real(ext_refs, pool_datastack_create(),
- &extrefs_arr))
+ &extrefs_arr)) {
+ *error_r = "Broken ext-refs string";
return 0;
+ }
psize = dbox_file_get_plaintext_size(file);
t_array_init(&streams, 8);
@@ -169,7 +174,10 @@
array_append(&streams, &input, 1);
i_stream_seek(*stream, (*stream)->v_offset + part_size);
if ((*stream)->v_offset + part_size > psize) {
- /* extrefs point outside message */
+ *error_r = t_strdup_printf(
+ "ext-refs point outside message "
+ "(%"PRIuUOFF_T" + %"PRIuUOFF_T" > %"PRIuUOFF_T")",
+ (*stream)->v_offset, part_size, psize);
ret = 0;
}
last_voffset += part_size;
@@ -192,8 +200,11 @@
}
if (psize != (*stream)->v_offset) {
- if (psize < (*stream)->v_offset) {
- /* extrefs point outside message */
+ if ((*stream)->v_offset > psize) {
+ *error_r = t_strdup_printf(
+ "ext-refs point outside message "
+ "(%"PRIuUOFF_T" > %"PRIuUOFF_T")",
+ (*stream)->v_offset, psize);
ret = 0;
} else {
uoff_t trailer_size = psize - (*stream)->v_offset;
@@ -215,7 +226,7 @@
int dbox_attachment_file_get_stream(struct dbox_file *file,
struct istream **stream)
{
- const char *ext_refs;
+ const char *ext_refs, *error;
int ret;
/* need to read metadata in case there are external references */
@@ -231,11 +242,12 @@
/* we have external references. */
T_BEGIN {
ret = dbox_attachment_file_get_stream_from(file, ext_refs,
- stream);
+ stream, &error);
+ if (ret == 0) {
+ dbox_file_set_corrupted(file,
+ "Corrupted ext-refs metadata %s: %s",
+ ext_refs, error);
+ }
} T_END;
- if (ret == 0) {
- dbox_file_set_corrupted(file, "Ext refs metadata corrupted: %s",
- ext_refs);
- }
return ret;
}
More information about the dovecot-cvs
mailing list