]> granicus.if.org Git - mutt/commitdiff
Convert smime_get_candidates() to use buffer pool.
authorKevin McCarthy <kevin@8t8.us>
Sun, 27 Oct 2019 03:09:00 +0000 (11:09 +0800)
committerKevin McCarthy <kevin@8t8.us>
Sun, 27 Oct 2019 03:09:00 +0000 (11:09 +0800)
smime.c

diff --git a/smime.c b/smime.c
index 141d093071df0bc19319f8aaed5994b5497f9674..fd996b0fe4c130e0dda9d34e03f9c89274392c63 100644 (file)
--- a/smime.c
+++ b/smime.c
@@ -597,7 +597,7 @@ static smime_key_t *smime_parse_key(char *buf)
 
 static smime_key_t *smime_get_candidates(char *search, short public)
 {
-  char index_file[_POSIX_PATH_MAX];
+  BUFFER *index_file;
   FILE *fp;
   char buf[LONG_STRING];
   smime_key_t *key, *results, **results_end;
@@ -605,14 +605,17 @@ static smime_key_t *smime_get_candidates(char *search, short public)
   results = NULL;
   results_end = &results;
 
-  snprintf(index_file, sizeof (index_file), "%s/.index",
-           public ? NONULL(SmimeCertificates) : NONULL(SmimeKeys));
+  index_file = mutt_buffer_pool_get ();
+  mutt_buffer_printf (index_file, "%s/.index",
+                      public ? NONULL(SmimeCertificates) : NONULL(SmimeKeys));
 
-  if ((fp = safe_fopen (index_file, "r")) == NULL)
+  if ((fp = safe_fopen (mutt_b2s (index_file), "r")) == NULL)
   {
-    mutt_perror (index_file);
+    mutt_perror (mutt_b2s (index_file));
+    mutt_buffer_pool_release (&index_file);
     return NULL;
   }
+  mutt_buffer_pool_release (&index_file);
 
   while (fgets (buf, sizeof (buf), fp))
   {