From: Timo Sirainen Date: Wed, 8 Nov 2017 12:11:51 +0000 (+0200) Subject: doveadm: client - Fail if server sends more than one VERSION reply in handshake X-Git-Tag: 2.3.0.rc1~457 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8a6710d679d728bc96090f1a587f3abd9bed2d91;p=thirdparty%2Fdovecot%2Fcore.git doveadm: client - Fail if server sends more than one VERSION reply in handshake --- diff --git a/src/doveadm/server-connection.c b/src/doveadm/server-connection.c index 9fe7a3427f..1bab9a358a 100644 --- a/src/doveadm/server-connection.c +++ b/src/doveadm/server-connection.c @@ -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) {