From: Timo Sirainen Date: Tue, 7 Feb 2023 22:19:30 +0000 (+0200) Subject: lib-storage: Fail if userdb returns key+=value for non-string X-Git-Tag: 2.4.0~2263 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cce8193bdf913c86690bbab212b809f4fcb2ad43;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Fail if userdb returns key+=value for non-string Previously an error was logged, but the user initialization didn't fail. However, it's safer to fail since it's a bad configuration. --- diff --git a/src/lib-storage/mail-storage-service.c b/src/lib-storage/mail-storage-service.c index cb20a52cf2..d5a08541df 100644 --- a/src/lib-storage/mail-storage-service.c +++ b/src/lib-storage/mail-storage-service.c @@ -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);