summaryrefslogtreecommitdiffstats
path: root/pgp.c
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2019-10-18 14:02:02 +0800
committerKevin McCarthy <kevin@8t8.us>2019-10-18 14:02:02 +0800
commitc1f9f00f6890eaaeb98af5cbe2a0aaf95a213431 (patch)
tree7e76db83359dc7d63b23f34a45f00598beba7d6f /pgp.c
parente750e39c4a80bb98e98c5fc38500e0897a3e0279 (diff)
Convert pgp_check_traditional_one_body() to use buffer pool.
Diffstat (limited to 'pgp.c')
-rw-r--r--pgp.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/pgp.c b/pgp.c
index 1e8adb6c..45fffd2e 100644
--- a/pgp.c
+++ b/pgp.c
@@ -721,28 +721,30 @@ out:
static int pgp_check_traditional_one_body (FILE *fp, BODY *b)
{
- char tempfile[_POSIX_PATH_MAX];
+ BUFFER *tempfile = NULL;
char buf[HUGE_STRING];
FILE *tfp;
+ int rc = 0;
short sgn = 0;
short enc = 0;
short key = 0;
if (b->type != TYPETEXT)
- return 0;
+ goto cleanup;
- mutt_mktemp (tempfile, sizeof (tempfile));
- if (mutt_decode_save_attachment (fp, b, tempfile, 0, 0) != 0)
+ tempfile = mutt_buffer_pool_get ();
+ mutt_buffer_mktemp (tempfile);
+ if (mutt_decode_save_attachment (fp, b, mutt_b2s (tempfile), 0, 0) != 0)
{
- unlink (tempfile);
- return 0;
+ unlink (mutt_b2s (tempfile));
+ goto cleanup;
}
- if ((tfp = fopen (tempfile, "r")) == NULL)
+ if ((tfp = fopen (mutt_b2s (tempfile), "r")) == NULL)
{
- unlink (tempfile);
- return 0;
+ unlink (mutt_b2s (tempfile));
+ goto cleanup;
}
while (fgets (buf, sizeof (buf), tfp))
@@ -758,10 +760,10 @@ static int pgp_check_traditional_one_body (FILE *fp, BODY *b)
}
}
safe_fclose (&tfp);
- unlink (tempfile);
+ unlink (mutt_b2s (tempfile));
if (!enc && !sgn && !key)
- return 0;
+ goto cleanup;
/* fix the content type */
@@ -773,7 +775,11 @@ static int pgp_check_traditional_one_body (FILE *fp, BODY *b)
else if (key)
mutt_set_parameter ("x-action", "pgp-keys", &b->parameter);
- return 1;
+ rc = 1;
+
+cleanup:
+ mutt_buffer_pool_release (&tempfile);
+ return rc;
}
int pgp_check_traditional (FILE *fp, BODY *b, int just_one)