From: Kevin McCarthy Date: Thu, 12 Sep 2019 02:40:48 +0000 (-0700) Subject: Convert query_pipe_attachment to use buffer pool. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=70bb4fad36350e9e657cb8cbf70d2617874b1b83;p=mutt Convert query_pipe_attachment to use buffer pool. --- diff --git a/attach.c b/attach.c index de58b553..de32d1fb 100644 --- a/attach.c +++ b/attach.c @@ -618,7 +618,7 @@ return_error: } /* returns 1 on success, 0 on error */ -int mutt_pipe_attachment (FILE *fp, BODY *b, const char *path, char *outfile) +int mutt_pipe_attachment (FILE *fp, BODY *b, const char *path, const char *outfile) { pid_t thepid; int out = -1; diff --git a/protos.h b/protos.h index 9373aaa0..038d12c6 100644 --- a/protos.h +++ b/protos.h @@ -379,7 +379,7 @@ int mutt_parse_score (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); int mutt_parse_unscore (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); int mutt_parse_unhook (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *); int mutt_pattern_func (int, char *); -int mutt_pipe_attachment (FILE *, BODY *, const char *, char *); +int mutt_pipe_attachment (FILE *, BODY *, const char *, const char *); int mutt_print_attachment (FILE *, BODY *); int mutt_query_complete (char *, size_t); int mutt_query_variables (LIST *queries); diff --git a/recvattach.c b/recvattach.c index fdb38562..9b00eeb8 100644 --- a/recvattach.c +++ b/recvattach.c @@ -612,39 +612,43 @@ cleanup: static void mutt_query_pipe_attachment (char *command, FILE *fp, BODY *body, int filter) { - char tfile[_POSIX_PATH_MAX]; - char warning[STRING+_POSIX_PATH_MAX]; + BUFFER *tfile = NULL, *warning = NULL; + + tfile = mutt_buffer_pool_get (); + warning = mutt_buffer_pool_get (); if (filter) { - snprintf (warning, sizeof (warning), + mutt_buffer_printf (warning, _("WARNING! You are about to overwrite %s, continue?"), body->filename); - if (mutt_yesorno (warning, MUTT_NO) != MUTT_YES) + if (mutt_yesorno (mutt_b2s (warning), MUTT_NO) != MUTT_YES) { mutt_window_clearline (MuttMessageWindow, 0); - return; + goto cleanup; } - mutt_mktemp (tfile, sizeof (tfile)); + mutt_buffer_mktemp (tfile); } - else - tfile[0] = 0; - if (mutt_pipe_attachment (fp, body, command, tfile)) + if (mutt_pipe_attachment (fp, body, command, mutt_b2s (tfile))) { if (filter) { mutt_unlink (body->filename); - mutt_rename_file (tfile, body->filename); + mutt_rename_file (mutt_b2s (tfile), body->filename); mutt_update_encoding (body); mutt_message _("Attachment filtered."); } } else { - if (filter && tfile[0]) - mutt_unlink (tfile); + if (filter && mutt_buffer_len (tfile)) + mutt_unlink (mutt_b2s (tfile)); } + +cleanup: + mutt_buffer_pool_release (&tfile); + mutt_buffer_pool_release (&warning); } static void pipe_attachment (FILE *fp, BODY *b, STATE *state)