aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2001-01-23 11:25:03 +0800
committerMichael Zucci <zucchi@src.gnome.org>2001-01-23 11:25:03 +0800
commit96be0c50f7dde84249db1194e69e8b146afc0687 (patch)
tree0dc092e539dcf3415b4edb6f8e0a4c1027504d7e /camel
parent096f54cfa0d3ec4916c3c27038ce2d609b5edbd0 (diff)
downloadgsoc2013-evolution-96be0c50f7dde84249db1194e69e8b146afc0687.tar.gz
gsoc2013-evolution-96be0c50f7dde84249db1194e69e8b146afc0687.tar.zst
gsoc2013-evolution-96be0c50f7dde84249db1194e69e8b146afc0687.zip
Removed some debug 'warnings', as they should now be displayed at the
2001-01-23 Not Zed <NotZed@Ximian.com> * providers/imap/camel-imap-summary.c (message_info_load): Removed some debug 'warnings', as they should now be displayed at the toplevel loader, and just made the code match similar code elsewhere. * providers/local/camel-mbox-summary.c (message_info_load): Error handling. (message_info_save): more error handling. * camel-folder-summary.c (message_info_load): Add error handling and sanity checking. (camel_folder_summary_load): Add error checks. (perform_content_info_load): Error + sanity checks. (content_info_load): error + sanity checks. svn path=/trunk/; revision=7737
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog15
-rw-r--r--camel/camel-folder-summary.c71
-rw-r--r--camel/providers/imap/camel-imap-summary.c17
-rw-r--r--camel/providers/local/camel-mbox-summary.c14
4 files changed, 87 insertions, 30 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 3fedcec679..ae517c44ab 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,20 @@
2001-01-23 Not Zed <NotZed@Ximian.com>
+ * providers/imap/camel-imap-summary.c (message_info_load): Removed
+ some debug 'warnings', as they should now be displayed at the
+ toplevel loader, and just made the code match similar code
+ elsewhere.
+
+ * providers/local/camel-mbox-summary.c (message_info_load): Error
+ handling.
+ (message_info_save): more error handling.
+
+ * camel-folder-summary.c (message_info_load): Add error handling
+ and sanity checking.
+ (camel_folder_summary_load): Add error checks.
+ (perform_content_info_load): Error + sanity checks.
+ (content_info_load): error + sanity checks.
+
* camel-filter-driver.c (close_folder): avoid /0 by updating after
we've done the sync.
(close_folders): Setup the first progress report to start it off.
diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c
index 147c8e452e..376aea12d8 100644
--- a/camel/camel-folder-summary.c
+++ b/camel/camel-folder-summary.c
@@ -498,7 +498,14 @@ perform_content_info_load(CamelFolderSummary *s, FILE *in)
CamelMessageContentInfo *ci, *part;
ci = ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->content_info_load(s, in);
- camel_folder_summary_decode_uint32(in, &count);
+ if (ci == NULL)
+ return NULL;
+
+ if (camel_folder_summary_decode_uint32(in, &count) == -1 || count > 500) {
+ camel_folder_summary_content_info_free(s, ci);
+ return NULL;
+ }
+
for (i=0;i<count;i++) {
part = perform_content_info_load(s, in);
if (part) {
@@ -506,6 +513,8 @@ perform_content_info_load(CamelFolderSummary *s, FILE *in)
part->parent = ci;
} else {
g_warning("Summary file format messed up?");
+ camel_folder_summary_content_info_free(s, ci);
+ return NULL;
}
}
return ci;
@@ -521,24 +530,26 @@ camel_folder_summary_load(CamelFolderSummary *s)
g_assert(s->summary_path);
in = fopen(s->summary_path, "r");
- if ( in == NULL ) {
+ if (in == NULL)
return -1;
- }
CAMEL_SUMMARY_LOCK(s, io_lock);
- if ( ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->summary_header_load(s, in) == -1) {
- fclose(in);
- CAMEL_SUMMARY_UNLOCK(s, io_lock);
- return -1;
- }
+ if ( ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->summary_header_load(s, in) == -1)
+ goto error;
/* now read in each message ... */
- /* FIXME: check returns */
for (i=0;i<s->saved_count;i++) {
mi = ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->message_info_load(s, in);
-
+
+ if (mi == NULL)
+ goto error;
+
if (s->build_content) {
mi->content = perform_content_info_load(s, in);
+ if (mi->content == NULL) {
+ camel_folder_summary_info_free(s, mi);
+ goto error;
+ }
}
camel_folder_summary_add(s, mi);
@@ -552,6 +563,14 @@ camel_folder_summary_load(CamelFolderSummary *s)
s->flags &= ~CAMEL_SUMMARY_DIRTY;
return 0;
+
+error:
+ g_warning("Cannot load summary file: %s", strerror(ferror(in)));
+ CAMEL_SUMMARY_UNLOCK(s, io_lock);
+ fclose(in);
+ s->flags |= ~CAMEL_SUMMARY_DIRTY;
+
+ return -1;
}
/* saves the content descriptions, recursively */
@@ -1790,7 +1809,9 @@ message_info_load(CamelFolderSummary *s, FILE *in)
camel_folder_summary_decode_fixed_int32(in, &mi->message_id.id.part.hi);
camel_folder_summary_decode_fixed_int32(in, &mi->message_id.id.part.lo);
- camel_folder_summary_decode_uint32(in, &count);
+ if (camel_folder_summary_decode_uint32(in, &count) == -1 || count > 500)
+ goto error;
+
if (count > 0) {
mi->references = g_malloc(sizeof(*mi->references) + ((count-1) * sizeof(mi->references->references[0])));
mi->references->size = count;
@@ -1800,7 +1821,9 @@ message_info_load(CamelFolderSummary *s, FILE *in)
}
}
- camel_folder_summary_decode_uint32(in, &count);
+ if (camel_folder_summary_decode_uint32(in, &count) == -1 || count > 500)
+ goto error;
+
for (i=0;i<count;i++) {
char *name;
camel_folder_summary_decode_string(in, &name);
@@ -1808,7 +1831,9 @@ message_info_load(CamelFolderSummary *s, FILE *in)
g_free(name);
}
- camel_folder_summary_decode_uint32(in, &count);
+ if (camel_folder_summary_decode_uint32(in, &count) == -1 || count > 500)
+ goto error;
+
for (i=0;i<count;i++) {
char *name, *value;
camel_folder_summary_decode_string(in, &name);
@@ -1818,7 +1843,13 @@ message_info_load(CamelFolderSummary *s, FILE *in)
g_free(value);
}
- return mi;
+ if (!ferror(in))
+ return mi;
+
+error:
+ camel_folder_summary_info_free(s, mi);
+
+ return NULL;
}
static int
@@ -1923,7 +1954,9 @@ content_info_load(CamelFolderSummary *s, FILE *in)
ct = header_content_type_new(type, subtype);
g_free(type); /* can this be removed? */
g_free(subtype);
- camel_folder_summary_decode_uint32(in, &count);
+ if (camel_folder_summary_decode_uint32(in, &count) == -1 || count > 500)
+ goto error;
+
for (i=0;i<count;i++) {
char *name, *value;
camel_folder_summary_decode_token(in, &name);
@@ -1942,7 +1975,13 @@ content_info_load(CamelFolderSummary *s, FILE *in)
camel_folder_summary_decode_uint32(in, &ci->size);
ci->childs = NULL;
- return ci;
+
+ if (!ferror(in))
+ return ci;
+
+error:
+ camel_folder_summary_content_info_free(s, ci);
+ return NULL;
}
static int
diff --git a/camel/providers/imap/camel-imap-summary.c b/camel/providers/imap/camel-imap-summary.c
index 74a024f760..66228649bc 100644
--- a/camel/providers/imap/camel-imap-summary.c
+++ b/camel/providers/imap/camel-imap-summary.c
@@ -169,20 +169,17 @@ message_info_load (CamelFolderSummary *s, FILE *in)
CamelImapMessageInfo *iinfo;
info = camel_imap_summary_parent->message_info_load (s, in);
- if (!info) {
- g_warning ("eek! encountered a NULL message info!");
- return NULL;
- }
- iinfo = (CamelImapMessageInfo *)info;
+ if (info) {
+ iinfo = (CamelImapMessageInfo *)info;
- if (camel_folder_summary_decode_uint32 (in, &iinfo->server_flags) == -1) {
- /* wouldn't it just be better to default to certain server flags here? */
- g_warning ("eek! problems decoding server flags!");
- camel_folder_summary_info_free (s, info);
- return NULL;
+ if (camel_folder_summary_decode_uint32 (in, &iinfo->server_flags) == -1)
+ goto error;
}
return info;
+error:
+ camel_folder_summary_info_free (s, info);
+ return NULL;
}
static int
diff --git a/camel/providers/local/camel-mbox-summary.c b/camel/providers/local/camel-mbox-summary.c
index 5b62743857..ab42e10df7 100644
--- a/camel/providers/local/camel-mbox-summary.c
+++ b/camel/providers/local/camel-mbox-summary.c
@@ -197,11 +197,15 @@ message_info_load(CamelFolderSummary *s, FILE *in)
mi = ((CamelFolderSummaryClass *)camel_mbox_summary_parent)->message_info_load(s, in);
if (mi) {
CamelMboxMessageInfo *mbi = (CamelMboxMessageInfo *)mi;
-
- camel_folder_summary_decode_off_t(in, &mbi->frompos);
+
+ if (camel_folder_summary_decode_off_t(in, &mbi->frompos) == -1)
+ goto error;
}
return mi;
+error:
+ camel_folder_summary_info_free(s, mi);
+ return NULL;
}
static int
@@ -211,9 +215,11 @@ message_info_save(CamelFolderSummary *s, FILE *out, CamelMessageInfo *mi)
io(printf("saving mbox message info\n"));
- ((CamelFolderSummaryClass *)camel_mbox_summary_parent)->message_info_save(s, out, mi);
+ if (((CamelFolderSummaryClass *)camel_mbox_summary_parent)->message_info_save(s, out, mi) == -1
+ || camel_folder_summary_encode_off_t(out, mbi->frompos) == -1)
+ return -1;
- return camel_folder_summary_encode_off_t(out, mbi->frompos);
+ return 0;
}
static int