From: Timo Sirainen Date: Thu, 13 Aug 2020 19:08:48 +0000 (+0300) Subject: log: log_connection_handshake() - Handle i_stream_read()'s -2 return value properly X-Git-Tag: 2.3.13~393 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=172e23fecb14fbb792d681e971fa6ad0ecc15249;p=thirdparty%2Fdovecot%2Fcore.git log: log_connection_handshake() - Handle i_stream_read()'s -2 return value properly Although this shouldn't happen anymore after the previous change. --- diff --git a/src/log/log-connection.c b/src/log/log-connection.c index 68ae31fbaa..82c9374a09 100644 --- a/src/log/log-connection.c +++ b/src/log/log-connection.c @@ -347,17 +347,17 @@ static int log_connection_handshake(struct log_connection *log) full handshake packet immediately. if not, treat it as an error message that we want to log. */ ret = i_stream_read(log->input); - if (ret < 0) { + if (ret == -1) { i_error("read(log %s) failed: %s", log->default_prefix, i_stream_get_error(log->input)); return -1; } - if ((size_t)ret < sizeof(handshake)) { + data = i_stream_get_data(log->input, &size); + if (size < sizeof(handshake)) { /* this isn't a handshake */ return 0; } - data = i_stream_get_data(log->input, &size); i_assert(size >= sizeof(handshake)); memcpy(&handshake, data, sizeof(handshake));