From: Timo Sirainen Date: Wed, 14 Mar 2012 12:59:24 +0000 (+0200) Subject: auth: Make sure auth cache doesn't break if any cache keys have TABs. X-Git-Tag: 2.1.2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ca283b86783042541e15cfd17ef253a2ce48aa71;p=thirdparty%2Fdovecot%2Fcore.git auth: Make sure auth cache doesn't break if any cache keys have TABs. --- diff --git a/src/auth/auth-cache.c b/src/auth/auth-cache.c index 5fea9f1968..1cf18f88c0 100644 --- a/src/auth/auth-cache.c +++ b/src/auth/auth-cache.c @@ -207,6 +207,15 @@ void auth_cache_clear(struct auth_cache *cache) hash_table_clear(cache->hash, FALSE); } +static const char * +auth_cache_escape(const char *string, + const struct auth_request *auth_request ATTR_UNUSED) +{ + /* cache key %variables are separated by tabs, make sure that there + are no tabs in the string */ + return str_tabescape(string); +} + const char * auth_cache_lookup(struct auth_cache *cache, const struct auth_request *request, const char *key, struct auth_cache_node **node_r, @@ -225,7 +234,7 @@ auth_cache_lookup(struct auth_cache *cache, const struct auth_request *request, str = t_str_new(256); var_expand(str, t_strconcat(request->userdb_lookup ? "U" : "P", "%!/", key, NULL), - auth_request_get_var_expand_table(request, NULL)); + auth_request_get_var_expand_table(request, auth_cache_escape)); node = hash_table_lookup(cache->hash, str_c(str)); if (node == NULL) { @@ -281,7 +290,7 @@ void auth_cache_insert(struct auth_cache *cache, struct auth_request *request, str = t_str_new(256); var_expand(str, t_strconcat(request->userdb_lookup ? "U" : "P", "%!/", key, NULL), - auth_request_get_var_expand_table(request, NULL)); + auth_request_get_var_expand_table(request, auth_cache_escape)); request->user = current_username; @@ -330,7 +339,7 @@ void auth_cache_remove(struct auth_cache *cache, str = t_str_new(256); var_expand(str, key, - auth_request_get_var_expand_table(request, NULL)); + auth_request_get_var_expand_table(request, auth_cache_escape)); node = hash_table_lookup(cache->hash, str_c(str)); if (node == NULL)