From 9fcbc8f335c4322c6e4167e0356bfb9802e5edb6 Mon Sep 17 00:00:00 2001 From: Not Zed Date: Wed, 24 Jul 2002 15:13:43 +0000 Subject: When writing the summary, use TRUNC flag, duh. Also, write to a temp file 2002-07-25 Not Zed * 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 * camel-partition-table.c (camel_key_table_next): Didn't unlock if we exited on an empty key list. svn path=/trunk/; revision=17570 --- camel/ChangeLog | 18 ++++++++++++++++++ camel/camel-folder-summary.c | 26 +++++++++++++++++++++++--- camel/camel-mime-parser.c | 7 +++---- camel/camel-mime-utils.c | 2 +- camel/camel-partition-table.c | 4 +++- camel/providers/local/camel-mbox-summary.c | 1 + 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 + + * 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 + * 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;isummary_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); } -- cgit v1.2.3