From: Timo Sirainen Date: Wed, 6 May 2020 13:26:34 +0000 (+0300) Subject: *-login: Remove redundant/early freeing of proxy_password X-Git-Tag: 2.3.13~668 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3e251ae8411fc4e30e50150aaf94b4f86afe6b4d;p=thirdparty%2Fdovecot%2Fcore.git *-login: Remove redundant/early freeing of proxy_password The login-common code already does this after the proxying has failed or succeeded. Having these duplicate frees immediately after sending the password isn't all that useful, and most importantly they make it impossible to reconnect after the password has been sent. --- diff --git a/src/imap-login/imap-proxy.c b/src/imap-login/imap-proxy.c index c0951f02fe..afcd8a6e9c 100644 --- a/src/imap-login/imap-proxy.c +++ b/src/imap-login/imap-proxy.c @@ -65,15 +65,6 @@ static void proxy_write_id(struct imap_client *client, string_t *str) str_append(str, ")\r\n"); } -static void proxy_free_password(struct client *client) -{ - if (client->proxy_password == NULL) - return; - - safe_memset(client->proxy_password, 0, strlen(client->proxy_password)); - i_free_and_null(client->proxy_password); -} - static int proxy_write_starttls(struct imap_client *client, string_t *str) { enum login_proxy_ssl_flags ssl_flags = login_proxy_get_ssl_flags(client->common.login_proxy); @@ -135,7 +126,6 @@ static int proxy_write_login(struct imap_client *client, string_t *str) str_append(str, "\r\n"); client->proxy_sent_state |= IMAP_PROXY_SENT_STATE_LOGIN; - proxy_free_password(&client->common); return 0; } @@ -169,7 +159,6 @@ static int proxy_write_login(struct imap_client *client, string_t *str) base64_encode(output, len, str); } str_append(str, "\r\n"); - proxy_free_password(&client->common); client->proxy_sent_state |= IMAP_PROXY_SENT_STATE_AUTHENTICATE; return 0; } diff --git a/src/pop3-login/pop3-proxy.c b/src/pop3-login/pop3-proxy.c index 43cf99afaa..de04ae7c60 100644 --- a/src/pop3-login/pop3-proxy.c +++ b/src/pop3-login/pop3-proxy.c @@ -17,15 +17,6 @@ static const char *pop3_proxy_state_names[POP3_PROXY_STATE_COUNT] = { "banner", "starttls", "xclient", "login1", "login2" }; -static void proxy_free_password(struct client *client) -{ - if (client->proxy_password == NULL) - return; - - safe_memset(client->proxy_password, 0, strlen(client->proxy_password)); - i_free_and_null(client->proxy_password); -} - static int proxy_send_login(struct pop3_client *client, struct ostream *output) { struct dsasl_client_settings sasl_set; @@ -102,7 +93,6 @@ static int proxy_send_login(struct pop3_client *client, struct ostream *output) str_append(str, "\r\n"); o_stream_nsend(output, str_data(str), str_len(str)); - proxy_free_password(&client->common); if (client->proxy_state != POP3_PROXY_XCLIENT) client->proxy_state = POP3_PROXY_LOGIN2; return 0; @@ -219,7 +209,6 @@ int pop3_proxy_parse_line(struct client *client, const char *line) /* USER successful, send PASS */ o_stream_nsend_str(output, t_strdup_printf( "PASS %s\r\n", client->proxy_password)); - proxy_free_password(client); pop3_client->proxy_state = POP3_PROXY_LOGIN2; return 0; case POP3_PROXY_LOGIN2: diff --git a/src/submission-login/submission-proxy.c b/src/submission-login/submission-proxy.c index 95a3f8928b..652d041c44 100644 --- a/src/submission-login/submission-proxy.c +++ b/src/submission-login/submission-proxy.c @@ -21,15 +21,6 @@ static const char *submission_proxy_state_names[SUBMISSION_PROXY_STATE_COUNT] = "banner", "ehlo", "starttls", "tls-ehlo", "xclient", "authenticate" }; -static void proxy_free_password(struct client *client) -{ - if (client->proxy_password == NULL) - return; - - safe_memset(client->proxy_password, 0, strlen(client->proxy_password)); - i_free_and_null(client->proxy_password); -} - static buffer_t * proxy_compose_xclient_forward(struct submission_client *client) { @@ -144,8 +135,6 @@ proxy_send_login(struct submission_client *client, struct ostream *output) str_append(str, "\r\n"); o_stream_nsend(output, str_data(str), str_len(str)); - proxy_free_password(&client->common); - if (client->proxy_state != SUBMISSION_PROXY_XCLIENT) client->proxy_state = SUBMISSION_PROXY_AUTHENTICATE; return 0;