From 852dd7c0557fef0ab651192175d93be09cf24be9 Mon Sep 17 00:00:00 2001 From: Rocco Rutte Date: Thu, 10 Jul 2008 22:02:47 +0200 Subject: [PATCH] Prevent some pointers of 'struct body' being saved to hcache This addresses the hcache safety issue but maybe doesn't fix it completely, see #2942. This also prevents mutt from crashing when using a hcache that was synced when syncing the mailbox (updating changed and fully-parsed messages). --- ChangeLog | 12 ++++++++++++ hcache.c | 34 +++++++++++++++++++++++----------- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 595eac730..8aab3bde6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2008-07-10 21:46 +0200 Aron Griffis (6244eefaea64) + + * headers.c: Remove completely wrong comment regarding in-reply-to and + references + + ...plus fix one other comment and some whitespace. + +2008-07-09 09:14 +0000 Rocco Rutte (2a9e9c487bad) + + * ChangeLog, doc/mutt.man, main.c: Document redirection to trigger + batch send mode in mutt(1) and mutt -h. Closes #2070. + 2008-07-04 09:09 +0200 Ralf Wildenhues (74b54f11c919) * protos.h: Fix syntax error for strtok_r compatitility prototype diff --git a/hcache.c b/hcache.c index af27b8274..2a988f5f7 100644 --- a/hcache.c +++ b/hcache.c @@ -362,19 +362,31 @@ restore_parameter(PARAMETER ** p, const unsigned char *d, int *off, int convert) static unsigned char * dump_body(BODY * c, unsigned char *d, int *off, int convert) { + BODY nb; + + memcpy (&nb, c, sizeof (BODY)); + + /* some fields are not safe to cache */ + nb.content = NULL; + nb.charset = NULL; + nb.next = NULL; + nb.parts = NULL; + nb.hdr = NULL; + nb.aptr = NULL; + lazy_realloc(&d, *off + sizeof (BODY)); - memcpy(d + *off, c, sizeof (BODY)); + memcpy(d + *off, &nb, sizeof (BODY)); *off += sizeof (BODY); - d = dump_char(c->xtype, d, off, 0); - d = dump_char(c->subtype, d, off, 0); + d = dump_char(nb.xtype, d, off, 0); + d = dump_char(nb.subtype, d, off, 0); - d = dump_parameter(c->parameter, d, off, convert); + d = dump_parameter(nb.parameter, d, off, convert); - d = dump_char(c->description, d, off, convert); - d = dump_char(c->form_name, d, off, convert); - d = dump_char(c->filename, d, off, convert); - d = dump_char(c->d_filename, d, off, convert); + d = dump_char(nb.description, d, off, convert); + d = dump_char(nb.form_name, d, off, convert); + d = dump_char(nb.filename, d, off, convert); + d = dump_char(nb.d_filename, d, off, convert); return d; } @@ -620,9 +632,9 @@ mutt_hcache_dump(header_cache_t *h, HEADER * header, int *off, memcpy(d + *off, &nh, sizeof (HEADER)); *off += sizeof (HEADER); - d = dump_envelope(header->env, d, off, convert); - d = dump_body(header->content, d, off, convert); - d = dump_char(header->maildir_flags, d, off, convert); + d = dump_envelope(nh.env, d, off, convert); + d = dump_body(nh.content, d, off, convert); + d = dump_char(nh.maildir_flags, d, off, convert); return d; } -- 2.40.0