aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2002-07-24 23:13:43 +0800
committerMichael Zucci <zucchi@src.gnome.org>2002-07-24 23:13:43 +0800
commit9fcbc8f335c4322c6e4167e0356bfb9802e5edb6 (patch)
tree86ad5969e40e256b8bedc65b813c9563c14cf40a
parent710ba7ca95b2fec221f7d0fd861e7f1d803aabec (diff)
downloadgsoc2013-evolution-9fcbc8f335c4322c6e4167e0356bfb9802e5edb6.tar.gz
gsoc2013-evolution-9fcbc8f335c4322c6e4167e0356bfb9802e5edb6.tar.zst
gsoc2013-evolution-9fcbc8f335c4322c6e4167e0356bfb9802e5edb6.zip
When writing the summary, use TRUNC flag, duh. Also, write to a temp file
2002-07-25 Not Zed <NotZed@Ximian.com> * camel-folder-summary.c (camel_folder_summary_save): When writing the summary, use TRUNC flag, duh. Also, write to a temp file first, and rename when closed successfully, and check ferror() and fclose() against 0 rather than -1. * providers/local/camel-mbox-summary.c (summary_update): Decrement i if we remove the summary item so we dont skip every 2nd one. * camel-mime-utils.c (header_decode_mailbox): Use rfc2047_decode_word explicitly incase we just found an encoded word. Stops us re-decoding the string twice, which fixes memory corruption in #26330 when the HUGE string is used later. 2002-07-24 Not Zed <NotZed@Ximian.com> * camel-partition-table.c (camel_key_table_next): Didn't unlock if we exited on an empty key list. svn path=/trunk/; revision=17570
-rw-r--r--camel/ChangeLog18
-rw-r--r--camel/camel-folder-summary.c26
-rw-r--r--camel/camel-mime-parser.c7
-rw-r--r--camel/camel-mime-utils.c2
-rw-r--r--camel/camel-partition-table.c4
-rw-r--r--camel/providers/local/camel-mbox-summary.c1
6 files changed, 49 insertions, 9 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 754e073700..a52716f7ed 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,23 @@
+2002-07-25 Not Zed <NotZed@Ximian.com>
+
+ * camel-folder-summary.c (camel_folder_summary_save): When writing
+ the summary, use TRUNC flag, duh. Also, write to a temp file
+ first, and rename when closed successfully, and check ferror() and
+ fclose() against 0 rather than -1.
+
+ * providers/local/camel-mbox-summary.c (summary_update): Decrement
+ i if we remove the summary item so we dont skip every 2nd one.
+
+ * camel-mime-utils.c (header_decode_mailbox): Use
+ rfc2047_decode_word explicitly incase we just found an encoded
+ word. Stops us re-decoding the string twice, which fixes memory
+ corruption in #26330 when the HUGE string is used later.
+
2002-07-24 Not Zed <NotZed@Ximian.com>
+ * camel-partition-table.c (camel_key_table_next): Didn't unlock if
+ we exited on an empty key list.
+
* providers/imap/camel-imap-folder.c (imap_expunge_uids_online):
Sync before doing an expunge if we dont have uidplus. See #25766.
(imap_expunge_uids_resyncing): Same here.
diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c
index 665ffab795..b7024ec84e 100644
--- a/camel/camel-folder-summary.c
+++ b/camel/camel-folder-summary.c
@@ -629,17 +629,23 @@ camel_folder_summary_save(CamelFolderSummary *s)
int i;
guint32 count;
CamelMessageInfo *mi;
+ char *path;
if (s->summary_path == NULL
|| (s->flags & CAMEL_SUMMARY_DIRTY) == 0)
return 0;
- fd = open(s->summary_path, O_RDWR|O_CREAT, 0600);
+ path = alloca(strlen(s->summary_path)+4);
+ sprintf(path, "%s~", s->summary_path);
+ fd = open(path, O_RDWR|O_CREAT|O_TRUNC, 0600);
if (fd == -1)
return -1;
out = fdopen(fd, "w");
if ( out == NULL ) {
+ i = errno;
+ unlink(path);
close(fd);
+ errno = i;
return -1;
}
@@ -648,13 +654,16 @@ camel_folder_summary_save(CamelFolderSummary *s)
CAMEL_SUMMARY_LOCK(s, io_lock);
if ( ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->summary_header_save(s, out) == -1) {
+ i = errno;
fclose(out);
CAMEL_SUMMARY_UNLOCK(s, io_lock);
+ unlink(path);
+ errno = i;
return -1;
}
/* now write out each message ... */
- /* FIXME: check returns */
+ /* we check ferorr when done for i/o errors */
count = s->messages->len;
for (i=0;i<count;i++) {
@@ -668,8 +677,19 @@ camel_folder_summary_save(CamelFolderSummary *s)
CAMEL_SUMMARY_UNLOCK(s, io_lock);
- if (fclose(out) == -1)
+ if (ferror(out) != 0 || fclose(out) != 0) {
+ i = errno;
+ unlink(path);
+ errno = i;
return -1;
+ }
+
+ if (rename(path, s->summary_path) == -1) {
+ i = errno;
+ unlink(path);
+ errno = i;
+ return -1;
+ }
s->flags &= ~CAMEL_SUMMARY_DIRTY;
return 0;
diff --git a/camel/camel-mime-parser.c b/camel/camel-mime-parser.c
index 1cf38e7f1a..4ecc945542 100644
--- a/camel/camel-mime-parser.c
+++ b/camel/camel-mime-parser.c
@@ -47,7 +47,7 @@
#define r(x)
#define h(x)
-#define c(x)
+#define c(x)
#define d(x)
/*#define PURIFY*/
@@ -1323,7 +1323,7 @@ folder_scan_header(struct _header_scan_state *s, int *lastone)
/* otherwise, complete header, add it */
s->outptr[0] = 0;
- h(printf("header '%.20s' at %d\n", s->outbuf, s->header_start));
+ h(printf("header '%.20s' at %d\n", s->outbuf, (int)s->header_start));
header_raw_append_parse(&h->headers, s->outbuf, s->header_start);
s->outptr = s->outbuf;
@@ -1739,8 +1739,7 @@ tail_recurse:
while (f) {
camel_mime_filter_filter(f->filter, *databuffer, *datalength, presize,
databuffer, datalength, &presize);
- d(printf ("Filtered content (%s): '",
- camel_type_to_name(((CamelObject *)f->filter)->s.type)));
+ d(printf("Filtered content (%s): '", ((CamelObject *)f->filter)->klass->name));
d(fwrite(*databuffer, sizeof(char), *datalength, stdout));
d(printf("'\n"));
f = f->next;
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c
index 1f3c10cfc6..e594a43ed4 100644
--- a/camel/camel-mime-utils.c
+++ b/camel/camel-mime-utils.c
@@ -2487,7 +2487,7 @@ header_decode_mailbox(const char **in)
g_free(text);
/* or maybe that we've added up a bunch of broken bits to make an encoded word */
- text = header_decode_string(name->str, NULL);
+ text = rfc2047_decode_word(name->str, name->len);
if (text) {
g_string_truncate(name, 0);
g_string_append(name, text);
diff --git a/camel/camel-partition-table.c b/camel/camel-partition-table.c
index 68e0e257b5..fad1a5e002 100644
--- a/camel/camel-partition-table.c
+++ b/camel/camel-partition-table.c
@@ -946,8 +946,10 @@ camel_key_table_next(CamelKeyTable *ki, camel_key_t next, char **keyp, unsigned
if (next == 0) {
next = ki->root->first;
- if (next == 0)
+ if (next == 0) {
+ CAMEL_KEY_TABLE_UNLOCK(ki, lock);
return 0;
+ }
} else
next++;
diff --git a/camel/providers/local/camel-mbox-summary.c b/camel/providers/local/camel-mbox-summary.c
index 3c5222406e..e84875aad0 100644
--- a/camel/providers/local/camel-mbox-summary.c
+++ b/camel/providers/local/camel-mbox-summary.c
@@ -416,6 +416,7 @@ summary_update(CamelLocalSummary *cls, off_t offset, CamelFolderChangeInfo *chan
camel_folder_change_info_remove_uid(changeinfo, camel_message_info_uid(mi));
camel_folder_summary_remove(s, mi);
count--;
+ i--;
}
camel_folder_summary_info_free(s, mi);
}