]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: auth-scram-server - Change return type of auth_scram_parse_client_final() to...
authorStephan Bosch <stephan.bosch@open-xchange.com>
Fri, 6 Jan 2023 13:22:07 +0000 (14:22 +0100)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 27 Jan 2023 09:34:54 +0000 (09:34 +0000)
src/auth/auth-scram-server.c
src/auth/mech-scram.c

index 3c2aee96719abaff14cca17606860718ead73e81..25fa48a3d9f4043f19f068d0eca1105c3287ef69 100644 (file)
@@ -241,7 +241,7 @@ auth_scram_server_verify_credentials(struct scram_auth_request *server)
                                      sizeof(stored_key));
 }
 
-static bool
+static int
 auth_scram_parse_client_final(struct scram_auth_request *server,
                              const unsigned char *data, size_t size,
                              const char **error_r)
@@ -263,7 +263,7 @@ auth_scram_parse_client_final(struct scram_auth_request *server,
        field_count = str_array_length(fields);
        if (field_count < 3) {
                *error_r = "Invalid final client message";
-               return FALSE;
+               return -1;
        }
 
        /* channel-binding = "c=" base64
@@ -282,7 +282,7 @@ auth_scram_parse_client_final(struct scram_auth_request *server,
 
        if (strcmp(fields[0], str_c(str)) != 0) {
                *error_r = "Invalid channel binding data";
-               return FALSE;
+               return -1;
        }
 
        /* nonce           = "r=" c-nonce [s-nonce]
@@ -293,7 +293,7 @@ auth_scram_parse_client_final(struct scram_auth_request *server,
        nonce_str = t_strconcat("r=", server->cnonce, server->snonce, NULL);
        if (strcmp(fields[1], nonce_str) != 0) {
                *error_r = "Wrong nonce";
-               return FALSE;
+               return -1;
        }
 
        /* proof           = "p=" base64
@@ -306,22 +306,22 @@ auth_scram_parse_client_final(struct scram_auth_request *server,
                if (base64_decode(&fields[field_count-1][2], len,
                                  server->proof) < 0) {
                        *error_r = "Invalid base64 encoding";
-                       return FALSE;
+                       return -1;
                }
                if (server->proof->used != hmethod->digest_size) {
                        *error_r = "Invalid ClientProof length";
-                       return FALSE;
+                       return -1;
                }
        } else {
                *error_r = "Invalid ClientProof";
-               return FALSE;
+               return -1;
        }
 
        (void)str_array_remove(fields, fields[field_count-1]);
        server->client_final_message_without_proof =
                p_strdup(server->pool, t_strarray_join(fields, ","));
 
-       return TRUE;
+       return 0;
 }
 
 static const char *
index 564502d4dd072b5af581d8f06cb6f5b29795fd23..c73b5e127aed758476a4e33550494c4636be0d10 100644 (file)
@@ -111,7 +111,7 @@ void mech_scram_auth_continue(struct auth_request *auth_request,
        } else {
                /* Received client-final-message */
                if (auth_scram_parse_client_final(request, data, data_size,
-                                                 &error)) {
+                                                 &error) >= 0) {
                        if (!auth_scram_server_verify_credentials(request)) {
                                e_info(auth_request->mech_event,
                                       AUTH_LOG_MSG_PASSWORD_MISMATCH);