From: Stephan Bosch Date: Sun, 18 Mar 2018 02:32:19 +0000 (+0100) Subject: lib-program-client: test-program-client-unix: Further fix error handling in test_prog... X-Git-Tag: 2.3.9~2098 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e5abc312ec38555a635505d68e101094c5490b72;p=thirdparty%2Fdovecot%2Fcore.git lib-program-client: test-program-client-unix: Further fix error handling in test_program_input(). --- diff --git a/src/lib-program-client/test-program-client-unix.c b/src/lib-program-client/test-program-client-unix.c index c06023064d..386bfd48ff 100644 --- a/src/lib-program-client/test-program-client-unix.c +++ b/src/lib-program-client/test-program-client-unix.c @@ -159,21 +159,25 @@ static void test_program_input(struct test_client *client) const char *line = ""; int ret = 0; - for (;;) { + while (ret >= 0) { if (client->state == CLIENT_STATE_BODY) { ret = test_program_input_handle(client, NULL); break; } - while (client->state != CLIENT_STATE_BODY && - (line=i_stream_read_next_line(client->in)) != NULL) { - if (test_program_input_handle(client, line) < 0) { + while (client->state < CLIENT_STATE_BODY) { + line = i_stream_read_next_line(client->in); + if (line == NULL) { + ret = 0; + break; + } + if ((ret=test_program_input_handle(client, line)) < 0) { i_warning("Client sent invalid line: %s", line); break; } } } - if (ret < 0) + if (ret < 0 || client->in->stream_errno != 0) return; if (!client->in->eof) return;