]> granicus.if.org Git - neomutt/commitdiff
Use Buffer instead of raw char* in pop
authorPietro Cerutti <gahr@gahr.ch>
Mon, 12 Aug 2019 13:08:49 +0000 (13:08 +0000)
committerPietro Cerutti <gahr@gahr.ch>
Mon, 12 Aug 2019 13:25:52 +0000 (13:25 +0000)
pop/pop.c
pop/pop_auth.c
pop/pop_lib.c
pop/pop_private.h

index 74c41f407fc42994a420f66e089413cb0702397b..e276be9b1c1a1b43777c0bfdfffff726780d1280 100644 (file)
--- a/pop/pop.c
+++ b/pop/pop.c
@@ -103,8 +103,8 @@ static void pop_adata_free(void **ptr)
   if (!ptr || !*ptr)
     return;
 
-  // struct PopAccountData *adata = *ptr;
-  // FREE(&adata->conn);
+  struct PopAccountData *adata = *ptr;
+  FREE(&adata->auth_list.data);
   FREE(ptr);
 }
 
index b9d180b792bb12a3f4fd684f46fac36b9857001c..f650f4922edd28adae0df780bc527f79a970dc28 100644 (file)
@@ -74,7 +74,7 @@ static enum PopAuthRes pop_auth_sasl(struct PopAccountData *adata, const char *m
   }
 
   if (!method)
-    method = adata->auth_list;
+    method = adata->auth_list.data;
 
   while (true)
   {
index 12617157a40dbf496ff792bed00e95cdb3cad780..a26df64cb40362bddf71dde49a47c37861ef6ef3 100644 (file)
@@ -129,9 +129,8 @@ static int fetch_capa(const char *line, void *data)
 
   if (mutt_str_startswith(line, "SASL", CASE_IGNORE))
   {
-    FREE(&adata->auth_list);
     const char *c = mutt_str_skip_email_wsp(line + 4);
-    adata->auth_list = mutt_str_strdup(c);
+    mutt_buffer_strcpy(&adata->auth_list, c);
   }
 
   else if (mutt_str_startswith(line, "STLS", CASE_IGNORE))
@@ -159,17 +158,11 @@ static int fetch_auth(const char *line, void *data)
 {
   struct PopAccountData *adata = data;
 
-  if (!adata->auth_list)
+  if (mutt_buffer_len(&adata->auth_list) != 0)
   {
-    adata->auth_list = mutt_mem_malloc(strlen(line) + 1);
-    *adata->auth_list = '\0';
+    mutt_buffer_addstr(&adata->auth_list, " ");
   }
-  else
-  {
-    mutt_mem_realloc(&adata->auth_list, strlen(adata->auth_list) + strlen(line) + 2);
-    strcat(adata->auth_list, " ");
-  }
-  strcat(adata->auth_list, line);
+  mutt_buffer_addstr(&adata->auth_list, line);
 
   return 0;
 }
@@ -201,7 +194,7 @@ static int pop_capabilities(struct PopAccountData *adata, int mode)
     adata->resp_codes = false;
     adata->expire = true;
     adata->login_delay = 0;
-    FREE(&adata->auth_list);
+    mutt_buffer_init(&adata->auth_list);
   }
 
   /* Execute CAPA command */
index 756c4d2115e831111b3f256d6a12a1e39b63d9d8..81ac671b375359dfb227a43cb9b642e724273e1a 100644 (file)
@@ -27,6 +27,7 @@
 #include <stdbool.h>
 #include <time.h>
 #include "conn/conn.h"
+#include "mutt/buffer.h"
 
 struct Mailbox;
 struct Progress;
@@ -91,7 +92,7 @@ struct PopAccountData
   size_t size;
   time_t check_time;
   time_t login_delay; /**< minimal login delay  capability */
-  char *auth_list;    /**< list of auth mechanisms */
+  struct Buffer auth_list; /**< list of auth mechanisms */
   char *timestamp;
   struct BodyCache *bcache; /**< body cache */
   char err_msg[POP_CMD_RESPONSE];