]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: Detect istream errors correctly.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 30 Oct 2017 13:58:43 +0000 (15:58 +0200)
committerTimo Sirainen <tss@dovecot.fi>
Mon, 30 Oct 2017 15:10:30 +0000 (17:10 +0200)
i_stream_is_eof() returns TRUE also when streams have an error, so all
errors were logged the same as a regular disconnection.

src/lib-http/http-header-parser.c
src/lib-http/test-http-client-errors.c

index 078775c1a24cd15b7420216d082132e3fddd456b..76ede04f8fa799854be9283a28507a684098d1c4 100644 (file)
@@ -356,7 +356,8 @@ int http_header_parse_next_field(struct http_header_parser *parser,
 
        i_assert(ret != -2);
        if (ret < 0) {
-               if (i_stream_is_eof(parser->input))
+               i_assert(parser->input->eof);
+               if (parser->input->stream_errno == 0)
                        *error_r = "Premature end of input";
                else
                        *error_r = "Stream error";
index 0c0bfc10f6af47e41440ec8059026c27b5ef24a0..fc0b7f62e8f9f175c888458282553ebddf2ee522 100644 (file)
@@ -1023,7 +1023,8 @@ test_connection_lost_input(struct server_connection *conn)
                return;
        }
        if (ret < 0) {
-               if (i_stream_is_eof(conn->conn.input))
+               i_assert(conn->conn.input->eof);
+               if (conn->conn.input->stream_errno == 0)
                        i_fatal("server: Client stream ended prematurely");
                else
                        i_fatal("server: Streem error: %s",