]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-program-client: test-program-client-unix: Further fix error handling in test_prog...
authorStephan Bosch <stephan.bosch@dovecot.fi>
Sun, 18 Mar 2018 02:32:19 +0000 (03:32 +0100)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Tue, 25 Jun 2019 09:22:30 +0000 (12:22 +0300)
src/lib-program-client/test-program-client-unix.c

index f44bf3475e9d6b6b29fa281753ef6b4c91ae06f6..d5e732350e9e63bba5c8b871f1e332eda1e146f4 100644 (file)
@@ -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;