Skip to content
Permalink
Browse files Browse the repository at this point in the history
imap: close connection on all failures
Thanks to Gabriel Salles-Loustau for spotting the problem.

Co-authored-by: Kevin McCarthy <kevin@8t8.us>
  • Loading branch information
flatcap and kevin8t8 committed Nov 17, 2020
1 parent f8b87cd commit 9c36717
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions imap/imap.c
Expand Up @@ -761,7 +761,7 @@ int imap_open_connection(struct ImapAccountData *adata)
else if ((ans = query_quadoption(C_SslStarttls,
_("Secure connection with TLS?"))) == MUTT_ABORT)
{
goto err_close_conn;
goto bail;
}
if (ans == MUTT_YES)
{
Expand All @@ -776,7 +776,7 @@ int imap_open_connection(struct ImapAccountData *adata)
if (mutt_ssl_starttls(adata->conn))
{
mutt_error(_("Could not negotiate TLS connection"));
goto err_close_conn;
goto bail;
}
else
{
Expand All @@ -791,7 +791,7 @@ int imap_open_connection(struct ImapAccountData *adata)
if (C_SslForceTls && (adata->conn->ssf == 0))
{
mutt_error(_("Encrypted connection unavailable"));
goto err_close_conn;
goto bail;
}
#endif
}
Expand All @@ -807,7 +807,7 @@ int imap_open_connection(struct ImapAccountData *adata)
if ((adata->conn->ssf == 0) && C_SslForceTls)
{
mutt_error(_("Encrypted connection unavailable"));
goto err_close_conn;
goto bail;
}
#endif

Expand All @@ -824,11 +824,8 @@ int imap_open_connection(struct ImapAccountData *adata)

return 0;

#ifdef USE_SSL
err_close_conn:
imap_close_connection(adata);
#endif
bail:
imap_close_connection(adata);
FREE(&adata->capstr);
return -1;
}
Expand Down

0 comments on commit 9c36717

Please sign in to comment.