]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
log: log_connection_handshake() - Handle i_stream_read()'s -2 return value properly
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 13 Aug 2020 19:08:48 +0000 (22:08 +0300)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 13 Aug 2020 19:08:48 +0000 (22:08 +0300)
Although this shouldn't happen anymore after the previous change.

src/log/log-connection.c

index 68ae31fbaa4fbecf0fa277e253a0c1d1a30f4360..82c9374a097506fd2168dbde2cb1b23d486cc2cd 100644 (file)
@@ -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));