Changeset 5451:b9ac445b035b for hcache.c

Show
Ignore:
Timestamp:
2008-07-10 13:02:47 (5 months ago)
Author:
Rocco Rutte <pdmef@…>
Branch:
HEAD
Message:

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).

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • hcache.c

    r5377 r5451  
    363363dump_body(BODY * c, unsigned char *d, int *off, int convert) 
    364364{ 
     365  BODY nb; 
     366 
     367  memcpy (&nb, c, sizeof (BODY)); 
     368 
     369  /* some fields are not safe to cache */ 
     370  nb.content = NULL; 
     371  nb.charset = NULL; 
     372  nb.next = NULL; 
     373  nb.parts = NULL; 
     374  nb.hdr = NULL; 
     375  nb.aptr = NULL; 
     376 
    365377  lazy_realloc(&d, *off + sizeof (BODY)); 
    366   memcpy(d + *off, c, sizeof (BODY)); 
     378  memcpy(d + *off, &nb, sizeof (BODY)); 
    367379  *off += sizeof (BODY); 
    368380 
    369   d = dump_char(c->xtype, d, off, 0); 
    370   d = dump_char(c->subtype, d, off, 0); 
    371  
    372   d = dump_parameter(c->parameter, d, off, convert); 
    373  
    374   d = dump_char(c->description, d, off, convert); 
    375   d = dump_char(c->form_name, d, off, convert); 
    376   d = dump_char(c->filename, d, off, convert); 
    377   d = dump_char(c->d_filename, d, off, convert); 
     381  d = dump_char(nb.xtype, d, off, 0); 
     382  d = dump_char(nb.subtype, d, off, 0); 
     383 
     384  d = dump_parameter(nb.parameter, d, off, convert); 
     385 
     386  d = dump_char(nb.description, d, off, convert); 
     387  d = dump_char(nb.form_name, d, off, convert); 
     388  d = dump_char(nb.filename, d, off, convert); 
     389  d = dump_char(nb.d_filename, d, off, convert); 
    378390 
    379391  return d; 
     
    621633  *off += sizeof (HEADER); 
    622634 
    623   d = dump_envelope(header->env, d, off, convert); 
    624   d = dump_body(header->content, d, off, convert); 
    625   d = dump_char(header->maildir_flags, d, off, convert); 
     635  d = dump_envelope(nh.env, d, off, convert); 
     636  d = dump_body(nh.content, d, off, convert); 
     637  d = dump_char(nh.maildir_flags, d, off, convert); 
    626638 
    627639  return d;