diff options
author | Lucian Langa <lucilanga@7pot.org> | 2023-10-23 14:00:59 +0100 |
---|---|---|
committer | Richard Russon <rich@flatcap.org> | 2023-10-23 14:06:50 +0100 |
commit | b78df3ef009dd6e4922d31746dc1bfd0247786e5 (patch) | |
tree | 23b80890fc189d14823dccdaae5ef7bd019d3585 | |
parent | 3a83e211dfaef53773c1eb01f9da0ea195ef792f (diff) |
nntp: fix use-after-free
Signed-off-by: Richard Russon <rich@flatcap.org>
-rw-r--r-- | index/functions.c | 3 | ||||
-rw-r--r-- | nntp/nntp.c | 5 |
2 files changed, 5 insertions, 3 deletions
diff --git a/index/functions.c b/index/functions.c index 05e3c423f..68954140f 100644 --- a/index/functions.c +++ b/index/functions.c @@ -2829,7 +2829,8 @@ static int op_main_change_group(struct IndexSharedData *shared, OptNews = true; const char *const c_news_server = cs_subset_string(shared->sub, "news_server"); - CurrentNewsSrv = nntp_select_server(shared->mailbox, c_news_server, false); + if (!CurrentNewsSrv) + CurrentNewsSrv = nntp_select_server(shared->mailbox, c_news_server, false); if (!CurrentNewsSrv) goto changefoldercleanup2; diff --git a/nntp/nntp.c b/nntp/nntp.c index 3c98d327f..1d4cbe278 100644 --- a/nntp/nntp.c +++ b/nntp/nntp.c @@ -2360,6 +2360,8 @@ static enum MxOpenReturns nntp_mbox_open(struct Mailbox *m) mutt_account_hook(m->realpath); struct NntpAccountData *adata = m->account->adata; if (!adata) + adata = CurrentNewsSrv; + if (!adata) { adata = nntp_select_server(m, server, true); m->account->adata = adata; @@ -2650,8 +2652,7 @@ static bool nntp_msg_open(struct Mailbox *m, struct Message *msg, struct Email * char buf[2048] = { 0 }; snprintf(buf, sizeof(buf), "ARTICLE %s\r\n", nntp_edata_get(e)->article_num ? article : e->env->message_id); - const int rc = nntp_fetch_lines(mdata, buf, sizeof(buf), fetch_msg, - fetch_tempfile, msg->fp); + const int rc = nntp_fetch_lines(mdata, buf, sizeof(buf), NULL, fetch_tempfile, msg->fp); if (rc) { mutt_file_fclose(&msg->fp); |