]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: connection - Use CONNECTION_DISCONNECT_HANDSHAKE_FAILED explicitly
authorAki Tuomi <aki.tuomi@dovecot.fi>
Wed, 28 Nov 2018 18:17:23 +0000 (20:17 +0200)
committerAki Tuomi <aki.tuomi@dovecot.fi>
Wed, 28 Nov 2018 18:17:23 +0000 (20:17 +0200)
Do not accidentically use it when connection was disconnected for
some other reason.

src/lib/connection.c

index 813f3c7488ec4cd25fad49ae7440b0b4a0b3423a..16f718aac9ea9a82e21765dbf328606ce72570c5 100644 (file)
@@ -79,6 +79,9 @@ void connection_input_default(struct connection *conn)
                                else if (ret == 0)
                                        /* continue reading */
                                        ret = 1;
+                               else
+                                       conn->disconnect_reason =
+                                               CONNECTION_DISCONNECT_HANDSHAKE_FAILED;
                        } else {
                                ret = conn->v.input_line(conn, line);
                        }
@@ -91,11 +94,10 @@ void connection_input_default(struct connection *conn)
                o_stream_unref(&output);
        }
        if (ret < 0 && !input->closed) {
-               enum connection_disconnect_reason reason;
-               if (conn->handshake_received)
+               enum connection_disconnect_reason reason =
+                       conn->disconnect_reason;
+               if (reason == CONNECTION_DISCONNECT_NOT)
                        reason = CONNECTION_DISCONNECT_DEINIT;
-               else
-                       reason = CONNECTION_DISCONNECT_HANDSHAKE_FAILED;
                connection_closed(conn, reason);
        }
        i_stream_unref(&input);
@@ -155,6 +157,8 @@ int connection_input_line_default(struct connection *conn, const char *line)
                        ret = 1; /* continue reading */
                else if (ret > 0)
                        conn->handshake_received = TRUE;
+               else
+                       conn->disconnect_reason = CONNECTION_DISCONNECT_HANDSHAKE_FAILED;
                return ret;
        } else if (!conn->handshake_received) {
                /* we don't do handshakes */