From: Stephan Bosch Date: Sat, 18 Mar 2023 15:12:11 +0000 (+0100) Subject: auth: auth-request-handler - Refactor auth_request_handler_find_mech() to reduce... X-Git-Tag: 2.4.2~242 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=537a260f24736b2e6151586ca4ca0ab9b2227f0a;p=thirdparty%2Fdovecot%2Fcore.git auth: auth-request-handler - Refactor auth_request_handler_find_mech() to reduce line length --- diff --git a/src/auth/auth-request-handler.c b/src/auth/auth-request-handler.c index e415acdc97..47d3010977 100644 --- a/src/auth/auth-request-handler.c +++ b/src/auth/auth-request-handler.c @@ -576,28 +576,30 @@ auth_request_handler_find_mech(struct auth_request_handler *handler, if (handler->token_auth) { mech = &mech_dovecot_token; - if (strcmp(mech_name, mech->mech_name) != 0) { - /* unsupported mechanism */ - e_error(handler->conn->conn.event, - "BUG: Authentication client %u requested invalid " - "authentication mechanism %s (DOVECOT-TOKEN required)", - handler->client_pid, - str_sanitize(mech_name, AUTH_SASL_MAX_MECH_NAME_LEN)); - return -1; - } - } else { - struct auth *auth_default = auth_default_protocol(); - mech = mech_register_find(auth_default->reg, mech_name); - if (mech == NULL) { - /* unsupported mechanism */ - e_error(handler->conn->conn.event, - "BUG: Authentication client %u requested unsupported " - "authentication mechanism %s", handler->client_pid, - str_sanitize(mech_name, AUTH_SASL_MAX_MECH_NAME_LEN)); - return -1; + if (strcmp(mech_name, mech->mech_name) == 0) { + *mech_r = mech; + return 0; } + /* unsupported mechanism */ + e_error(handler->conn->conn.event, + "BUG: Authentication client %u requested invalid " + "authentication mechanism %s (DOVECOT-TOKEN required)", + handler->client_pid, + str_sanitize(mech_name, AUTH_SASL_MAX_MECH_NAME_LEN)); + return -1; } + struct auth *auth_default = auth_default_protocol(); + + mech = mech_register_find(auth_default->reg, mech_name); + if (mech == NULL) { + /* unsupported mechanism */ + e_error(handler->conn->conn.event, + "BUG: Authentication client %u requested unsupported " + "authentication mechanism %s", handler->client_pid, + str_sanitize(mech_name, AUTH_SASL_MAX_MECH_NAME_LEN)); + return -1; + } *mech_r = mech; return 0; }