From: Timo Sirainen Date: Mon, 30 Oct 2017 13:58:43 +0000 (+0200) Subject: lib-http: Detect istream errors correctly. X-Git-Tag: 2.3.0.rc1~696 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=53393ea8bd72644c808f77cf0b79189376769d5d;p=thirdparty%2Fdovecot%2Fcore.git lib-http: Detect istream errors correctly. i_stream_is_eof() returns TRUE also when streams have an error, so all errors were logged the same as a regular disconnection. --- diff --git a/src/lib-http/http-header-parser.c b/src/lib-http/http-header-parser.c index 078775c1a2..76ede04f8f 100644 --- a/src/lib-http/http-header-parser.c +++ b/src/lib-http/http-header-parser.c @@ -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"; diff --git a/src/lib-http/test-http-client-errors.c b/src/lib-http/test-http-client-errors.c index 0c0bfc10f6..fc0b7f62e8 100644 --- a/src/lib-http/test-http-client-errors.c +++ b/src/lib-http/test-http-client-errors.c @@ -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",