]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Fail if userdb returns key+=value for non-string
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 7 Feb 2023 22:19:30 +0000 (00:19 +0200)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 20 Nov 2023 12:20:55 +0000 (14:20 +0200)
Previously an error was logged, but the user initialization didn't fail.
However, it's safer to fail since it's a bad configuration.

src/lib-storage/mail-storage-service.c

index cb20a52cf25a97e0e8e23a61b59b787a12be5e6a..d5a08541df85185c522c74fa8f9760e4eeb14b3f 100644 (file)
@@ -119,12 +119,10 @@ static int set_keyvalue(struct mail_storage_service_ctx *ctx,
                        const char **error_r)
 {
        struct setting_parser_context *set_parser = user->set_parser;
-       const char *orig_key, *append_value = NULL;
+       const char *append_value = NULL;
        size_t len;
        int ret;
 
-       orig_key = key;
-
        len = strlen(key);
        if (len > 0 && key[len-1] == '+') {
                /* key+=value */
@@ -152,14 +150,12 @@ static int set_keyvalue(struct mail_storage_service_ctx *ctx,
                enum setting_type type;
 
                old_value = settings_parse_get_value(set_parser, key, &type);
-               if (old_value != NULL && type == SET_STR) {
-                       const char *const *strp = old_value;
-
-                       value = t_strconcat(*strp, append_value, NULL);
-               } else {
-                       e_error(user->event, "Ignoring %s userdb setting. "
-                               "'+' can only be used for strings.", orig_key);
+               if (old_value == NULL || type != SET_STR) {
+                       *error_r = "'+' can only be used for strings";
+                       return -1;
                }
+               const char *const *strp = old_value;
+               value = t_strconcat(*strp, append_value, NULL);
        }
 
        ret = settings_parse_keyvalue(set_parser, key, value);