From: Aki Tuomi Date: Fri, 25 Jul 2025 08:51:16 +0000 (+0300) Subject: auth: auth-cache - Change auth_cache_parse_key_exclude() to return error X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d12bb78b5a235f31c9d5a655bd223c28d44bcadb;p=thirdparty%2Fdovecot%2Fcore.git auth: auth-cache - Change auth_cache_parse_key_exclude() to return error Simplifies following commit --- diff --git a/src/auth/auth-cache.c b/src/auth/auth-cache.c index ad8cbe5078..407e5d4aa0 100644 --- a/src/auth/auth-cache.c +++ b/src/auth/auth-cache.c @@ -64,8 +64,10 @@ static void auth_cache_key_add_tab_idx(string_t *str, unsigned int i) str_append_c(str, '}'); } -static char *auth_cache_parse_key_exclude(pool_t pool, const char *query, - const char *exclude_driver) +static int auth_cache_parse_key_exclude(pool_t pool, const char *query, + const char *exclude_driver, + char **cache_key_r, + const char **error_r) { string_t *str; bool key_seen[AUTH_REQUEST_VAR_TAB_COUNT]; @@ -76,9 +78,9 @@ static char *auth_cache_parse_key_exclude(pool_t pool, const char *query, struct var_expand_program *prog; if (var_expand_program_create(query, &prog, &error) < 0) { - e_debug(auth_event, "auth-cache: var_expand_program_create('%s') failed: %s", - query, error); - return p_strdup(pool, ""); + *error_r = t_strdup_printf("var_expand_program_create(%s) failed: %s", + query, error); + return -1; } const char *const *vars = var_expand_program_variables(prog); @@ -117,7 +119,8 @@ static char *auth_cache_parse_key_exclude(pool_t pool, const char *query, var_expand_program_free(&prog); - return p_strdup(pool, str_c(str)); + *cache_key_r = p_strdup(pool, str_c(str)); + return 0; } char *auth_cache_parse_key(pool_t pool, const char *query) @@ -140,7 +143,15 @@ char *auth_cache_parse_key_and_fields(pool_t pool, const char *query, } query = str_c(full_query); } - return auth_cache_parse_key_exclude(pool, query, exclude_driver); + + char *cache_key; + const char *error; + if (auth_cache_parse_key_exclude(pool, query, exclude_driver, + &cache_key, &error) < 0) { + e_debug(auth_event, "auth-cache: %s", error); + cache_key = p_strdup(pool, ""); + } + return cache_key; } static void