goto bailout;
}
- mutt_free_body (&b);
+ body_list_wipe(&b);
}
}
}
b = mutt_make_file_attach (nbuf);
if (b != NULL) {
mutt_view_attachment (NULL, b, M_REGULAR, NULL, NULL, 0);
- mutt_free_body (&b);
+ body_list_wipe(&b);
menu->redraw = REDRAW_FULL;
}
else
b->force_charset |= charset_changed ? 1 : 0;
if (!is_multipart(b) && b->parts)
- mutt_free_body (&b->parts);
+ body_list_wipe(&b->parts);
if (!mutt_is_message_type (b->type, b->subtype) && b->hdr) {
b->hdr->content = NULL;
header_delete(&b->hdr);
idx[x]->content->next = NULL;
idx[x]->content->parts = NULL;
- mutt_free_body (&(idx[x]->content));
+ body_list_wipe(&(idx[x]->content));
p_delete(&idx[x]->tree);
p_delete(&idx[x]);
for (; x < *idxlen - 1; x++)
idx[idxlen]->content->parts = NULL;
if (idx[idxlen]->unowned)
idx[idxlen]->content->unlink = 0;
- mutt_free_body (&idx[idxlen]->content);
+ body_list_wipe(&idx[idxlen]->content);
p_delete(&idx[idxlen]->tree);
p_delete(&idx[idxlen]);
}
Context->vsize -= body->length - new_length;
body->length = new_length;
- mutt_free_body (&body->parts);
+ body_list_wipe(&body->parts);
}
return 0;
fseeko (fp, cur->offset, 0);
if (mutt_copy_bytes (fp, fpout, cur->length) == -1) {
fclose (fp);
- mutt_free_body (&cur);
+ body_list_wipe(&cur);
return (-1);
}
- mutt_free_body (&cur);
+ body_list_wipe(&cur);
fclose (fp);
}
else {
if ((flags & M_CM_UPDATE) && (flags & M_CM_NOHEADER) == 0
&& new_offset != -1) {
body->offset = new_offset;
- mutt_free_body (&body->parts);
+ body_list_wipe(&body->parts);
}
return rc;
mustfree = 1;
fstat (fileno (s->fpin), &st);
- b = mutt_new_body ();
+ b = body_new();
b->length = (long) st.st_size;
b->parts = mutt_parse_multipart(s->fpin,
parameter_getval(a->parameter, "boundary"),
}
if (mustfree)
- mutt_free_body (&a);
+ body_list_wipe(&a);
return (rc);
}
if (a->encoding == ENCBASE64 || a->encoding == ENCQUOTEDPRINTABLE ||
a->encoding == ENCUUENCODED) {
fstat (fileno (s->fpin), &st);
- b = mutt_new_body ();
+ b = body_new();
b->length = (long) st.st_size;
b->parts = mutt_parse_messageRFC822 (s->fpin, b);
}
if (a->encoding == ENCBASE64 || a->encoding == ENCQUOTEDPRINTABLE ||
a->encoding == ENCUUENCODED)
- mutt_free_body (&b);
+ body_list_wipe(&b);
return (rc);
}
if (a->encoding == ENCBASE64 || a->encoding == ENCQUOTEDPRINTABLE ||
a->encoding == ENCUUENCODED) {
fstat (fileno (s->fpin), &st);
- b = mutt_new_body ();
+ b = body_new();
b->length = (long) st.st_size;
b->parts = mutt_parse_multipart(s->fpin,
parameter_getval(a->parameter, "boundary"),
if (a->encoding == ENCBASE64 || a->encoding == ENCQUOTEDPRINTABLE ||
a->encoding == ENCUUENCODED)
- mutt_free_body (&b);
+ body_list_wipe(&b);
return (rc);
}
h->env = envelope_new();
restore_envelope (h->env, d, &off);
- h->content = mutt_new_body ();
+ h->content = body_new();
restore_body (h->content, d, &off);
restore_char (&h->maildir_flags, d, &off);
return NULL;
}
- t = mutt_new_body ();
+ t = body_new();
t->type = TYPEMULTIPART;
t->subtype = m_strdup("signed");
t->encoding = ENC7BIT;
t->parts = a;
a = t;
- t->parts->next = mutt_new_body ();
+ t->parts->next = body_new();
t = t->parts->next;
t->type = TYPEAPPLICATION;
if (use_smime) {
if (!outfile)
return NULL;
- t = mutt_new_body ();
+ t = body_new();
t->type = TYPEMULTIPART;
t->subtype = m_strdup("encrypted");
t->encoding = ENC7BIT;
parameter_set_boundary(&t->parameter);
parameter_setval(&t->parameter, "protocol", "application/pgp-encrypted");
- t->parts = mutt_new_body ();
+ t->parts = body_new();
t->parts->type = TYPEAPPLICATION;
t->parts->subtype = m_strdup("pgp-encrypted");
t->parts->encoding = ENC7BIT;
- t->parts->next = mutt_new_body ();
+ t->parts->next = body_new();
t->parts->next->type = TYPEAPPLICATION;
t->parts->next->subtype = m_strdup("octet-stream");
t->parts->next->encoding = ENC7BIT;
if (!outfile)
return NULL;
- t = mutt_new_body ();
+ t = body_new();
t->type = TYPEAPPLICATION;
t->subtype = m_strdup("pkcs7-mime");
parameter_setval(&t->parameter, "name", "smime.p7m");
bb->offset = saved_b_offset;
fclose (tmpfp);
rewind (*fpout);
- mutt_free_body (cur);
+ body_list_wipe(cur);
*cur = tmp_b;
}
return *cur ? 0 : -1;
: _("[-- End of PGP/MIME encrypted data --]\n"), s);
}
- mutt_free_body (&tattach);
+ body_list_wipe(&tattach);
}
fclose (fpout);
_("[-- End of S/MIME encrypted data --]\n"), s);
}
- mutt_free_body (&tattach);
+ body_list_wipe(&tattach);
}
fclose (fpout);
which tmp_smime_pbody->parts after signing. */
tmp_smime_pbody->parts = tmp_smime_pbody->parts->next;
msg->content->next = NULL;
- mutt_free_body (&tmp_smime_pbody);
+ body_list_wipe(&tmp_smime_pbody);
}
pbody = tmp_pbody;
}
/* remove the outer multipart layer */
tmp_pgp_pbody = mutt_remove_multipart (tmp_pgp_pbody);
/* get rid of the signature */
- mutt_free_body (&tmp_pgp_pbody->next);
+ body_list_wipe(&tmp_pgp_pbody->next);
}
return (-1);
*/
if (flags != msg->security) {
tmp_pgp_pbody = mutt_remove_multipart (tmp_pgp_pbody);
- mutt_free_body (&tmp_pgp_pbody->next);
+ body_list_wipe(&tmp_pgp_pbody->next);
}
}
}
state_attach_puts (_("[-- End of PGP/MIME encrypted data --]\n"), s);
}
- mutt_free_body (&tattach);
+ body_list_wipe(&tattach);
/* clear 'Invoking...' message, since there's no error */
mutt_message _("PGP message successfully decrypted.");
} else {
return (NULL); /* fatal error while signing */
}
- t = mutt_new_body ();
+ t = body_new();
t->type = TYPEMULTIPART;
t->subtype = m_strdup("signed");
t->encoding = ENC7BIT;
t->parts = a;
a = t;
- t->parts->next = mutt_new_body ();
+ t->parts->next = body_new();
t = t->parts->next;
t->type = TYPEAPPLICATION;
t->subtype = m_strdup("pgp-signature");
return (NULL);
}
- t = mutt_new_body ();
+ t = body_new();
t->type = TYPEMULTIPART;
t->subtype = m_strdup("encrypted");
t->encoding = ENC7BIT;
parameter_set_boundary(&t->parameter);
parameter_setval(&t->parameter, "protocol", "application/pgp-encrypted");
- t->parts = mutt_new_body ();
+ t->parts = body_new();
t->parts->type = TYPEAPPLICATION;
t->parts->subtype = m_strdup("pgp-encrypted");
t->parts->encoding = ENC7BIT;
- t->parts->next = mutt_new_body ();
+ t->parts->next = body_new();
t->parts->next->type = TYPEAPPLICATION;
t->parts->next->subtype = m_strdup("octet-stream");
t->parts->next->encoding = ENC7BIT;
return NULL;
}
- b = mutt_new_body ();
+ b = body_new();
b->encoding = ENC7BIT;
fclose (tempfp);
fclose (devnull);
- att = mutt_new_body ();
+ att = body_new();
att->filename = m_strdup(tempf);
att->unlink = 1;
att->use_disp = 0;
return (NULL);
}
- t = mutt_new_body ();
+ t = body_new();
t->type = TYPEAPPLICATION;
t->subtype = m_strdup("x-pkcs7-mime");
parameter_setval(&t->parameter, "name", "smime.p7m");
return (NULL); /* fatal error while signing */
}
- t = mutt_new_body ();
+ t = body_new();
t->type = TYPEMULTIPART;
t->subtype = m_strdup("signed");
t->encoding = ENC7BIT;
t->parts = a;
a = t;
- t->parts->next = mutt_new_body ();
+ t->parts->next = body_new();
t = t->parts->next;
t->type = TYPEAPPLICATION;
t->subtype = m_strdup("x-pkcs7-signature");
/****************************************************************************/
typedef struct body {
+ struct body *next; /* next attachment in the list */
+
char *xtype; /* content-type if x-unknown */
char *subtype; /* content-type subtype */
parameter_t *parameter; /* parameters of the content-type */
* to determine what content-transfer-encoding
* is required when sending mail.
*/
- struct body *next; /* next attachment in the list */
struct body *parts; /* parts of a multipart or message/rfc822 */
struct header *hdr; /* header information for message/rfc822 */
unsigned int attach_qualifies:1;
} BODY;
+static inline BODY *body_init(BODY *b) {
+ b->disposition = DISPATTACH;
+ b->use_disp = 1;
+ return b;
+}
+void body_wipe(BODY *);
+
+DO_NEW(BODY, body);
+DO_DELETE(BODY, body);
+DO_SLIST(BODY, body, body_delete);
+
/****************************************************************************/
/* rfc822 Headers */
#include <lib-lib/ascii.h>
#include <lib-lib/url.h>
-#include "mime-types.h"
+#include "mime.h"
#include "mutt.h"
string_list_wipe(&p->userhdrs);
}
+void body_wipe(BODY *b)
+{
+ if (b->parameter)
+ parameter_list_wipe(&b->parameter);
+
+ if (b->unlink && b->filename) {
+ unlink (b->filename);
+ }
+
+ p_delete(&b->filename);
+ p_delete(&b->content);
+ p_delete(&b->xtype);
+ p_delete(&b->subtype);
+ p_delete(&b->description);
+ p_delete(&b->form_name);
+
+ if (b->hdr) {
+ /* Don't free twice (b->hdr->content = b->parts) */
+ b->hdr->content = NULL;
+ header_delete(&b->hdr);
+ }
+
+ if (b->parts)
+ body_list_wipe(&b->parts);
+}
+
void header_wipe(HEADER *h)
{
envelope_delete(&h->env);
- mutt_free_body (&h->content);
+ body_list_wipe(&h->content);
p_delete(&h->maildir_flags);
p_delete(&h->tree);
p_delete(&h->path);
*/
BODY *mutt_read_mime_header(FILE *fp, int digest)
{
- BODY *body = mutt_new_body ();
+ BODY *body = body_new();
char *line = p_new(char, LONG_STRING);
ssize_t linelen = LONG_STRING;
char *p;
*/
if (new->offset > end_off) {
- mutt_free_body(&new);
+ body_list_wipe(&new);
break;
}
off_t loc;
if (hdr && !hdr->content) {
- hdr->content = mutt_new_body ();
+ hdr->content = body_new();
/* set the defaults from RFC1521 */
hdr->content->type = TYPETEXT;
*/
newOffset[i - first].body =
ftello (fp) - ctx->hdrs[i]->content->length + offset;
- mutt_free_body (&ctx->hdrs[i]->content->parts);
+ body_list_wipe(&ctx->hdrs[i]->content->parts);
switch (ctx->magic) {
case M_MMDF:
h->lines = old_hdr_lines;
}
- mutt_free_body (&h->content->parts);
+ body_list_wipe(&h->content->parts);
return rc;
}
#define SW (option(OPTMBOXPANE)?SidebarWidth:0)
-BODY *mutt_new_body (void)
-{
- BODY *p = p_new(BODY, 1);
-
- p->disposition = DISPATTACH;
- p->use_disp = 1;
- return (p);
-}
-
-
/* Modified by blong to accept a "suggestion" for file name. If
* that file exists, then construct one with unique name but
* keep any extension. This might fail, I guess.
if (mutt_save_attachment (fp, src, tmp, 0, NULL) == -1)
return -1;
- *tgt = mutt_new_body ();
+ *tgt = body_new();
b = *tgt;
memcpy (b, src, sizeof (BODY));
return 0;
}
-
-static void body_wipe(BODY *b)
-{
- if (b->parameter)
- parameter_list_wipe(&b->parameter);
-
- if (b->unlink && b->filename) {
- unlink (b->filename);
- }
-
- p_delete(&b->filename);
- p_delete(&b->content);
- p_delete(&b->xtype);
- p_delete(&b->subtype);
- p_delete(&b->description);
- p_delete(&b->form_name);
-
- if (b->hdr) {
- /* Don't free twice (b->hdr->content = b->parts) */
- b->hdr->content = NULL;
- header_delete(&b->hdr);
- }
-
- if (b->parts)
- mutt_free_body(&b->parts);
-}
-
-DO_DELETE(BODY, body);
-
-void mutt_free_body(BODY **p)
-{
- while (*p) {
- BODY *b = *p;
- *p = b->next;
-
- body_delete(&b);
- }
-}
-
HEADER *mutt_dup_header (HEADER * h)
{
HEADER *hnew;
hdr->env = envelope_new();
hdr->env->newsgroups = m_strdup(nntp_data->group);
- hdr->content = mutt_new_body ();
+ hdr->content = body_new();
hdr->content->type = TYPETEXT;
hdr->content->subtype = m_strdup("plain");
hdr->content->encoding = ENC7BIT;
else {
mutt_parse_mime_message(ctx, h);
count = mutt_count_body_parts(h, 0);
- mutt_free_body(&h->content->parts);
+ body_list_wipe(&h->content->parts);
}
return (pat->not ^ (count >= pat->min && (pat->max == M_MAXRANGE ||
err:
mx_close_message (&msg);
envelope_delete(&newhdr->env);
- mutt_free_body (&newhdr->content);
+ body_list_wipe(&newhdr->content);
mutt_error _("Decryption failed.");
return -1;
}
- mutt_free_body (&newhdr->content);
+ body_list_wipe(&newhdr->content);
newhdr->content = b;
mutt_clear_error ();
newhdr->security |= APPLICATION_SMIME;
/* destroy the signature */
- mutt_free_body (&newhdr->content->parts->next);
+ body_list_wipe(&newhdr->content->parts->next);
newhdr->content = mutt_remove_multipart (newhdr->content);
}
mutt_stamp_attachment (b);
- mutt_free_body (&b->parts);
+ body_list_wipe(&b->parts);
if (b->hdr)
b->hdr->content = NULL; /* avoid dangling pointer */
}
if (rv == -1) {
envelope_delete(&newhdr->env);
- mutt_free_body (&newhdr->content);
+ body_list_wipe(&newhdr->content);
}
return rv;
BODY *mutt_make_message_attach (CONTEXT *, HEADER *, int);
BODY *mutt_remove_multipart (BODY *);
BODY *mutt_make_multipart (BODY *);
-BODY *mutt_new_body(void);
CONTENT *mutt_get_content_info (const char *fname, BODY * b);
void mutt_format_s_tree (char *, ssize_t, const char *, const char *);
void mutt_forward_intro (FILE * fp, HEADER * cur);
void mutt_forward_trailer (FILE * fp);
-void mutt_free_body (BODY **);
void mutt_free_color (int fg, int bg);
void mutt_generate_header (char *, ssize_t, HEADER *, int);
void mutt_help (int);
cur = NULL;
secured = !crypt_smime_decrypt_mime (_fp, &fp, _cur, &cur);
- mutt_free_body (&_cur);
+ body_list_wipe(&_cur);
safe_fclose (&_fp);
}
}
if (need_secured && secured) {
fclose (fp);
- mutt_free_body (&cur);
+ body_list_wipe(&cur);
}
mutt_menuDestroy (&menu);
}
if (!(flags & (SENDKEY | SENDPOSTPONED | SENDRESEND))) {
- pbody = mutt_new_body ();
+ pbody = body_new();
pbody->next = msg->content; /* don't kill command-line attachments */
msg->content = pbody;
if (save_sig) {
/* cleanup the second signature structures */
if (save_content->parts) {
- mutt_free_body (&save_content->parts->next);
+ body_list_wipe(&save_content->parts->next);
save_content->parts = NULL;
}
- mutt_free_body (&save_content);
+ body_list_wipe(&save_content);
/* restore old signature and attachments */
msg->content->parts->next = save_sig;
}
else if (save_content) {
/* destroy the new encrypted body. */
- mutt_free_body (&save_content);
+ body_list_wipe(&save_content);
}
}
if ((msg->security & ENCRYPT)
|| ((msg->security & SIGN)
&& msg->content->type == TYPEAPPLICATION)) {
- mutt_free_body (&msg->content); /* destroy PGP data */
+ body_list_wipe(&msg->content); /* destroy PGP data */
msg->content = clear_content; /* restore clear text. */
}
else if ((msg->security & SIGN) && msg->content->type == TYPEMULTIPART) {
- mutt_free_body (&msg->content->parts->next); /* destroy sig */
+ body_list_wipe(&msg->content->parts->next); /* destroy sig */
msg->content = mutt_remove_multipart (msg->content);
}
p_delete(&pgpkeylist);
if (free_clear_content)
- mutt_free_body (&clear_content);
+ body_list_wipe(&clear_content);
if (flags & SENDREPLY) {
if (cur && ctx)
return;
}
a->length = sb.st_size;
- mutt_free_body (&a->parts);
+ body_list_wipe(&a->parts);
a->hdr->content = NULL;
}
if ((fp = safe_fopen (buffer, "w+")) == NULL)
return NULL;
- body = mutt_new_body ();
+ body = body_new();
body->type = TYPEMESSAGE;
body->subtype = m_strdup("rfc822");
body->filename = m_strdup(buffer);
BODY *att;
CONTENT *info;
- att = mutt_new_body ();
+ att = body_new();
att->filename = m_strdup(path);
/* Attempt to determine the appropriate content-type based on the filename
#endif
if ((info = mutt_get_content_info (path, att)) == NULL) {
- mutt_free_body (&att);
+ body_list_wipe(&att);
return NULL;
}
{
BODY *new;
- new = mutt_new_body ();
+ new = body_new();
new->type = TYPEMULTIPART;
new->subtype = m_strdup("mixed");
new->encoding = get_toplevel_encoding (b);
t = b;
b = b->parts;
t->parts = NULL;
- mutt_free_body (&t);
+ body_list_wipe(&t);
}
return b;
}