X-Git-Url: https://git.llucax.com/software/mutt-debian.git/blobdiff_plain/14c29200cb58d3c4a0830265f2433849781858d0..e0765f8ab8243c097213733be0d4be2a31448b89:/recvattach.c?ds=inline diff --git a/recvattach.c b/recvattach.c index 1a46288..d9d87bc 100644 --- a/recvattach.c +++ b/recvattach.c @@ -1,6 +1,6 @@ /* - * Copyright (C) 1996-2000 Michael R. Elkins - * Copyright (C) 1999-2000 Thomas Roessler + * Copyright (C) 1996-2000,2002,2007 Michael R. Elkins + * Copyright (C) 1999-2006 Thomas Roessler * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,7 +30,6 @@ #include "attach.h" #include "mapping.h" #include "mx.h" -#include "copy.h" #include "mutt_crypt.h" #include @@ -56,7 +55,7 @@ static struct mapping_t AttachHelp[] = { { N_("Pipe"), OP_PIPE }, { N_("Print"), OP_PRINT }, { N_("Help"), OP_HELP }, - { NULL } + { NULL, 0 } }; void mutt_update_tree (ATTACHPTR **idx, short idxlen) @@ -254,7 +253,7 @@ const char *mutt_attach_fmt (char *dest, char path[_POSIX_PATH_MAX]; strfcpy (path, aptr->content->filename, sizeof (path)); - mutt_pretty_mailbox (path); + mutt_pretty_mailbox (path, sizeof (path)); mutt_format_s (dest, destlen, prefix, path); } else @@ -277,8 +276,17 @@ const char *mutt_attach_fmt (char *dest, case 'I': if (!optional) { - snprintf (dest, destlen, "%c", - (aptr->content->disposition == DISPINLINE) ? 'I' : 'A'); + const char dispchar[] = { 'I', 'A', 'F', '-' }; + char ch; + + if (aptr->content->disposition < sizeof(dispchar)) + ch = dispchar[aptr->content->disposition]; + else + { + dprint(1, (debugfile, "ERROR: invalid content-disposition %d\n", aptr->content->disposition)); + ch = '!'; + } + snprintf (dest, destlen, "%c", ch); } break; case 'm': @@ -363,7 +371,7 @@ const char *mutt_attach_fmt (char *dest, return (src); } -void attach_entry (char *b, size_t blen, MUTTMENU *menu, int num) +static void attach_entry (char *b, size_t blen, MUTTMENU *menu, int num) { mutt_FormatString (b, blen, 0, NONULL (AttachFormat), mutt_attach_fmt, (unsigned long) (((ATTACHPTR **)menu->data)[num]), M_FORMAT_ARROWCURSOR); } @@ -434,7 +442,10 @@ static int mutt_query_save_attachment (FILE *fp, BODY *body, HEADER *hdr, char * { if (mutt_get_field (prompt, buf, sizeof (buf), M_FILE | M_CLEAR) != 0 || !buf[0]) + { + mutt_clear_error (); return -1; + } prompt = NULL; mutt_expand_path (buf, sizeof (buf)); @@ -519,7 +530,7 @@ void mutt_save_attachment_list (FILE *fp, int tag, BODY *top, HEADER *hdr, MUTTM if (rc == 0 && AttachSep && (fpout = fopen (tfile,"a")) != NULL) { fprintf(fpout, "%s", AttachSep); - fclose (fpout); + safe_fclose (&fpout); } } else @@ -528,7 +539,7 @@ void mutt_save_attachment_list (FILE *fp, int tag, BODY *top, HEADER *hdr, MUTTM if (rc == 0 && AttachSep && (fpout = fopen (tfile,"a")) != NULL) { fprintf(fpout, "%s", AttachSep); - fclose (fpout); + safe_fclose (&fpout); } } } @@ -582,7 +593,7 @@ mutt_query_pipe_attachment (char *command, FILE *fp, BODY *body, int filter) CLEARLINE (LINES-1); return; } - mutt_mktemp (tfile); + mutt_mktemp (tfile, sizeof (tfile)); } else tfile[0] = 0; @@ -623,7 +634,7 @@ static void pipe_attachment (FILE *fp, BODY *b, STATE *state) return; } mutt_copy_stream (ifp, state->fpout); - fclose (ifp); + safe_fclose (&ifp); if (AttachSep) state_puts (AttachSep, state); } @@ -672,7 +683,7 @@ void mutt_pipe_attachment_list (FILE *fp, int tag, BODY *top, int filter) mutt_endwin (NULL); thepid = mutt_create_filter (buf, &state.fpout, NULL, NULL); pipe_attachment_list (buf, fp, tag, top, filter, &state); - fclose (state.fpout); + safe_fclose (&state.fpout); if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY)) mutt_any_key_to_continue (NULL); } @@ -732,13 +743,13 @@ static void print_attachment_list (FILE *fp, int tag, BODY *top, STATE *state) char newfile[_POSIX_PATH_MAX] = ""; FILE *ifp; - mutt_mktemp (newfile); + mutt_mktemp (newfile, sizeof (newfile)); if (mutt_decode_save_attachment (fp, top, newfile, M_PRINTING, 0) == 0) { if ((ifp = fopen (newfile, "r")) != NULL) { mutt_copy_stream (ifp, state->fpout); - fclose (ifp); + safe_fclose (&ifp); if (AttachSep) state_puts (AttachSep, state); } @@ -772,7 +783,7 @@ void mutt_print_attachment_list (FILE *fp, int tag, BODY *top) memset (&state, 0, sizeof (STATE)); thepid = mutt_create_filter (NONULL (PrintCmd), &state.fpout, NULL, NULL); print_attachment_list (fp, tag, top, &state); - fclose (state.fpout); + safe_fclose (&state.fpout); if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY)) mutt_any_key_to_continue (NULL); } @@ -780,7 +791,7 @@ void mutt_print_attachment_list (FILE *fp, int tag, BODY *top) print_attachment_list (fp, tag, top, &state); } -void +static void mutt_update_attach_index (BODY *cur, ATTACHPTR ***idxp, short *idxlen, short *idxmax, MUTTMENU *menu) @@ -1005,8 +1016,7 @@ void mutt_view_attachments (HEADER *hdr) cur = hdr->content; } - menu = mutt_new_menu (); - menu->menu = MENU_ATTACH; + menu = mutt_new_menu (MENU_ATTACH); menu->title = _("Attachments"); menu->make_entry = attach_entry; menu->tag = mutt_tag_attach; @@ -1244,7 +1254,7 @@ void mutt_view_attachments (HEADER *hdr) if (WithCrypto && need_secured && secured) { - fclose (fp); + safe_fclose (&fp); mutt_free_body (&cur); }