]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-oauth2: test-oauth2-json - Increment pos more carefully
authorAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 27 Sep 2023 07:31:28 +0000 (10:31 +0300)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Tue, 3 Oct 2023 08:22:08 +0000 (11:22 +0300)
src/lib-oauth2/test-oauth2-json.c

index 121b8a106519113304f9f28021a73ef553ddc655..3e50931b2ff7d860888d0fe135654c106ebeee4d 100644 (file)
@@ -75,10 +75,10 @@ static void test_oauth2_json_valid(void)
        cb_got_called = FALSE;
 
        /* Parse the JSON response */
-       for (pos = 0; pos <= strlen(test_input); pos +=2) {
+       for (pos = 0;; pos += 2) {
                test_istream_set_size(req->is, pos);
                oauth2_request_parse_json(req);
-               if (req->is == NULL)
+               if (pos >= strlen(test_input))
                        break;
        }
 
@@ -130,10 +130,10 @@ static void test_oauth2_json_error(void)
        cb_got_called = FALSE;
 
        /* Parse the JSON response */
-       for (size_t pos = 0; pos <= strlen(test_input_1); pos +=2) {
+       for (size_t pos = 0;; pos += 2) {
                test_istream_set_size(req->is, pos);
                oauth2_request_parse_json(req);
-               if (req->is == NULL)
+               if (pos >= strlen(test_input_1))
                        break;
        }
 
@@ -151,10 +151,10 @@ static void test_oauth2_json_error(void)
        cb_got_called = FALSE;
 
        /* Parse the JSON response */
-       for (size_t pos = 0; pos <= strlen(test_input_2); pos +=2) {
+       for (size_t pos = 0;; pos += 2) {
                test_istream_set_size(req->is, pos);
                oauth2_request_parse_json(req);
-               if (req->is == NULL)
+               if (pos >= strlen(test_input_2))
                        break;
        }