]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap-login: Prevent memory leak if ID command gets disconnected before finishing
authorKarl Fleischmann <karl.fleischmann@open-xchange.com>
Wed, 22 Mar 2023 07:57:25 +0000 (08:57 +0100)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 31 Mar 2023 05:54:46 +0000 (05:54 +0000)
src/imap-login/imap-login-client.c
src/imap-login/imap-login-client.h
src/imap-login/imap-login-cmd-id.c

index 38794e08219d197521dc7bafda5d12bcaa690d1b..b894713f12e5e0b0268cc0fe0286a8b75d13c960 100644 (file)
@@ -390,6 +390,13 @@ static void imap_client_destroy(struct client *client)
 {
        struct imap_client *imap_client = (struct imap_client *)client;
 
+       /* Prevent memory leak of ID command if client got disconnected before
+          command was finished. */
+       if (imap_client->cmd_id != NULL) {
+               i_assert(!imap_client->cmd_finished);
+               cmd_id_free(imap_client);
+       }
+
        i_free_and_null(imap_client->proxy_backend_capability);
        imap_parser_unref(&imap_client->parser);
 }
index 002829ba3a8340f54365ddd7b61cd7b2f9c69c44..6259ec5d8d14b4ef3cfe5a8b29cb6d3e31d452f8 100644 (file)
@@ -93,5 +93,6 @@ bool client_handle_parser_error(struct imap_client *client,
                                struct imap_parser *parser);
 
 int cmd_id(struct imap_client *client);
+void cmd_id_free(struct imap_client *client);
 
 #endif
index 57d635b9a7a45de10fc0eba472619a19c40c3c1c..e2d050d6a94786ace4ce797115eecbdb05576d9f 100644 (file)
@@ -229,7 +229,7 @@ static void cmd_id_finish(struct imap_client *client)
        client_send_reply(&client->common, IMAP_CMD_REPLY_OK, msg);
 }
 
-static void cmd_id_free(struct imap_client *client)
+void cmd_id_free(struct imap_client *client)
 {
        struct imap_client_cmd_id *id = client->cmd_id;