]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: mech-oauth2 - Iterate fields in safer manner
authorAki Tuomi <aki.tuomi@open-xchange.com>
Mon, 24 May 2021 15:55:28 +0000 (18:55 +0300)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Mon, 24 May 2021 15:55:28 +0000 (18:55 +0300)
Static analyser wasn't happy about the previous way.

src/auth/mech-oauth2.c

index 180b99fc3665140891d5b6910ca8abd452c69930..1b145674b3b2568a154f05978735e07d376cf66c 100644 (file)
@@ -58,10 +58,9 @@ static void oauth2_verify_callback(enum passdb_result result,
                if (request->mech_password != NULL)
                        request->mech_password = NULL;
                string_t *error = t_str_new(64);
-               unsigned int nfields = str_array_length(error_fields);
-               i_assert(nfields % 2 == 0);
                str_append_c(error, '{');
-               for (unsigned int i = 0; i < nfields; i += 2) {
+               for (unsigned int i = 0; error_fields[i] != NULL; i += 2) {
+                       i_assert(error_fields[i+1] != NULL);
                        if (i > 0)
                                str_append_c(error, ',');
                        str_append_c(error, '"');