From d85ac4d4762a8f2feb33b2426e2bcbd4c8a74e34 Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Fri, 18 Oct 2019 14:29:56 +0800 Subject: [PATCH] Convert pgp_extract_keys_from_attachment() to use buffer pool Upstream-commit: https://gitlab.com/muttmua/mutt/commit/f3bfb7d105854f53428b98de95d920e6f5ebad0e Co-authored-by: Richard Russon --- ncrypt/pgp.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/ncrypt/pgp.c b/ncrypt/pgp.c index 71b7befce..f7bb0aef8 100644 --- a/ncrypt/pgp.c +++ b/ncrypt/pgp.c @@ -944,14 +944,14 @@ cleanup: static void pgp_extract_keys_from_attachment(FILE *fp, struct Body *top) { struct State s = { 0 }; - char tempfname[PATH_MAX]; + struct Buffer *tempfname = mutt_buffer_pool_get(); - mutt_mktemp(tempfname, sizeof(tempfname)); - FILE *fp_tmp = mutt_file_fopen(tempfname, "w"); + mutt_buffer_mktemp(tempfname); + FILE *fp_tmp = mutt_file_fopen(mutt_b2s(tempfname), "w"); if (!fp_tmp) { - mutt_perror(tempfname); - return; + mutt_perror(mutt_b2s(tempfname)); + goto cleanup; } s.fp_in = fp; @@ -961,10 +961,13 @@ static void pgp_extract_keys_from_attachment(FILE *fp, struct Body *top) mutt_file_fclose(&fp_tmp); - pgp_class_invoke_import(tempfname); + pgp_class_invoke_import(mutt_b2s(tempfname)); mutt_any_key_to_continue(NULL); - mutt_file_unlink(tempfname); + mutt_file_unlink(mutt_b2s(tempfname)); + +cleanup: + mutt_buffer_pool_release(&tempfname); } /** -- 2.40.0