]> granicus.if.org Git - mutt/commitdiff
Convert query_pipe_attachment to use buffer pool.
authorKevin McCarthy <kevin@8t8.us>
Thu, 12 Sep 2019 02:40:48 +0000 (19:40 -0700)
committerKevin McCarthy <kevin@8t8.us>
Fri, 13 Sep 2019 22:15:41 +0000 (15:15 -0700)
attach.c
protos.h
recvattach.c

index de58b55381b67e33b1e2a90d0d2ffa14f3851d4a..de32d1fbdfb4271f63dc96d52ffe241cbf0b78ff 100644 (file)
--- 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;
index 9373aaa0db0e61b57201080af4c7f6e29f481866..038d12c60f439a342dcbdb708b2e5f8c9026eb33 100644 (file)
--- 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);
index fdb38562f2152525395f374c116d9ae81ac05ca5..9b00eeb8f03617c85943cac73565e24e19d373a4 100644 (file)
@@ -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)