X-Git-Url: https://git.llucax.com/software/mutt-debian.git/blobdiff_plain/19304f7c526fbe36ba0db2fb80bcaf3bd974d81d..9ae284163f491c64de122fcd555019040e0d4da7:/recvattach.c?ds=inline diff --git a/recvattach.c b/recvattach.c index 86448ff..d9d87bc 100644 --- a/recvattach.c +++ b/recvattach.c @@ -55,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) @@ -276,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': @@ -433,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)); @@ -518,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 @@ -527,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); } } } @@ -581,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; @@ -622,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); } @@ -671,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); } @@ -731,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); } @@ -771,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); } @@ -1242,7 +1254,7 @@ void mutt_view_attachments (HEADER *hdr) if (WithCrypto && need_secured && secured) { - fclose (fp); + safe_fclose (&fp); mutt_free_body (&cur); }