From 11b56c39f03be2ea100a5cca193a05f50217cded Mon Sep 17 00:00:00 2001 From: mintsuki Date: Sun, 14 Aug 2022 14:45:20 +0200 Subject: [PATCH] config: Only make keys global if before first entry --- common/lib/config.c | 16 +++++++++++++--- common/lib/config.h | 2 -- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/common/lib/config.c b/common/lib/config.c index 5e273aa4..f64a20dd 100644 --- a/common/lib/config.c +++ b/common/lib/config.c @@ -8,7 +8,8 @@ #include #include -#include +static bool config_get_entry_name(char *ret, size_t index, size_t limit); +static char *config_get_entry(size_t *size, size_t index); #define SEPARATOR '\n' @@ -285,10 +286,19 @@ overflow: menu_tree = create_menu_tree(NULL, 1, 0); + size_t s; + char *c = config_get_entry(&s, 0); + while (*c != ':') { + c--; + } + if (c > config_addr) { + c[-1] = 0; + } + return 0; } -bool config_get_entry_name(char *ret, size_t index, size_t limit) { +static bool config_get_entry_name(char *ret, size_t index, size_t limit) { if (!config_ready) return false; @@ -318,7 +328,7 @@ bool config_get_entry_name(char *ret, size_t index, size_t limit) { return true; } -char *config_get_entry(size_t *size, size_t index) { +static char *config_get_entry(size_t *size, size_t index) { if (!config_ready) return NULL; diff --git a/common/lib/config.h b/common/lib/config.h index 9ea2f016..6ae5794a 100644 --- a/common/lib/config.h +++ b/common/lib/config.h @@ -29,8 +29,6 @@ int init_config_disk(struct volume *part); int init_config_pxe(void); int init_config(size_t config_size); -bool config_get_entry_name(char *ret, size_t index, size_t limit); -char *config_get_entry(size_t *size, size_t index); char *config_get_value(const char *config, size_t index, const char *key); struct conf_tuple config_get_tuple(const char *config, size_t index, const char *key1, const char *key2);