]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-settings, config: Panic if SETTING_DEFINE_LIST_END is missing from settings lists
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 15 May 2025 10:26:30 +0000 (13:26 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Mon, 16 Jun 2025 12:45:51 +0000 (12:45 +0000)
src/config/config-parser.c
src/lib-settings/settings-parser.h

index b7ddab89191cb4533de564cf2d4746f42747be68..654f918594fb150b7a4f91cf05f0d402990d58e4 100644 (file)
@@ -2910,10 +2910,17 @@ config_parser_add_info(struct config_parser_context *ctx,
        const struct setting_parser_info *info = all_infos[info_idx];
        struct config_parser_key *config_key, *old_config_key;
        const char *name;
+       unsigned int i = 0;
 
-       for (unsigned int i = 0; info->defines[i].key != NULL; i++) {
+       for (i = 0; info->defines[i].key != NULL; i++) {
                const struct setting_define *def = &info->defines[i];
 
+               if ((info->defines[i].flags & SET_FLAG_EOL) != 0) {
+                       i_panic("struct %s key %s contains SET_FLAG_EOL",
+                               info->name, def->key);
+               }
+
+               i_assert((def->flags & SET_FLAG_EOL) == 0);
                if (def->type == SET_STR ||
                    def->type == SET_STR_NOVARS ||
                    def->type == SET_ENUM) {
@@ -2949,6 +2956,10 @@ config_parser_add_info(struct config_parser_context *ctx,
                        DLLIST_PREPEND(&old_config_key, config_key);
                hash_table_update(ctx->all_keys, def->key, config_key);
        }
+       if ((info->defines[i].flags & SET_FLAG_EOL) == 0) {
+               i_panic("struct %s is missing SETTING_DEFINE_LIST_END",
+                       info->name);
+       }
 }
 
 static void
index f2bbd4b95cc81fa5e03833871dc89f51a7330c35..3af52dda7fe39e764990f17b63f5e9bd55dcb6c8 100644 (file)
@@ -49,6 +49,8 @@ enum setting_type {
 };
 enum setting_flags {
        SET_FLAG_HIDDEN = BIT(0),
+       /* Used only for SETTING_DEFINE_LIST_END */
+       SET_FLAG_EOL = BIT(1),
 };
 
 enum setting_apply_flags {
@@ -58,7 +60,7 @@ enum setting_apply_flags {
        SETTING_APPLY_FLAG_NO_EXPAND = BIT(1),
 };
 
-#define SETTING_DEFINE_LIST_END { 0, 0, NULL, 0, NULL, NULL, NULL }
+#define SETTING_DEFINE_LIST_END { 0, SET_FLAG_EOL, NULL, 0, NULL, NULL, NULL }
 
 struct setting_filter_array_order {
        const struct setting_parser_info *info;