]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
doveadm: client - Fail if server sends more than one VERSION reply in handshake
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 8 Nov 2017 12:11:51 +0000 (14:11 +0200)
committerTimo Sirainen <tss@dovecot.fi>
Wed, 15 Nov 2017 20:24:08 +0000 (22:24 +0200)
src/doveadm/server-connection.c

index 9fe7a3427f40d17dc28e0531589f61ea7a5377d9..1bab9a358ac7eae1bdd89f6eb9fa1a03b89a6f20 100644 (file)
@@ -60,6 +60,7 @@ struct server_connection {
 
        enum server_reply_state state;
 
+       bool version_received:1;
        bool authenticate_sent:1;
        bool authenticated:1;
        bool streaming:1;
@@ -346,7 +347,11 @@ static void server_connection_input(struct server_connection *conn)
 
        if (!conn->authenticated) {
                while((line = i_stream_read_next_line(conn->input)) != NULL) {
-                       if (strncmp(line, "VERSION\t", 8) == 0) {
+                       /* Allow VERSION before or after the "+" or "-" line,
+                          because v2.2.33 sent the version after and newer
+                          versions send before. */
+                       if (!conn->version_received &&
+                           strncmp(line, "VERSION\t", 8) == 0) {
                                if (!version_string_verify_full(line, "doveadm-client",
                                                                DOVEADM_SERVER_PROTOCOL_VERSION_MAJOR,
                                                                &conn->minor)) {
@@ -355,6 +360,7 @@ static void server_connection_input(struct server_connection *conn)
                                        server_connection_destroy(&conn);
                                        return;
                                }
+                               conn->version_received = TRUE;
                                continue;
                        }
                        if (strcmp(line, "+") == 0) {