From: Pietro Cerutti Date: Mon, 12 Aug 2019 13:08:49 +0000 (+0000) Subject: Use Buffer instead of raw char* in pop X-Git-Tag: 2019-10-25~102 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=59ad00106ae61115e995b1ed4f395ba23adeeecf;p=neomutt Use Buffer instead of raw char* in pop --- diff --git a/pop/pop.c b/pop/pop.c index 74c41f407..e276be9b1 100644 --- 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); } diff --git a/pop/pop_auth.c b/pop/pop_auth.c index b9d180b79..f650f4922 100644 --- a/pop/pop_auth.c +++ b/pop/pop_auth.c @@ -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) { diff --git a/pop/pop_lib.c b/pop/pop_lib.c index 12617157a..a26df64cb 100644 --- a/pop/pop_lib.c +++ b/pop/pop_lib.c @@ -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 */ diff --git a/pop/pop_private.h b/pop/pop_private.h index 756c4d211..81ac671b3 100644 --- a/pop/pop_private.h +++ b/pop/pop_private.h @@ -27,6 +27,7 @@ #include #include #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];