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.7~214 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7b81473755cb783037dd2464b3d57c7e0ed55fe5;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 f44bf3475e..d5e732350e 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;