aboutsummaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-10-07 16:34:48 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-10-11 17:24:08 +0000
commit852fc049c860fc9004101fcb5cecfead719d04cc (patch)
tree1a7c281263bb3bca454bbf36cc0382878cd55906 /config.c
parentchangelog: trackpad scrolling: ‘multiplier’ is in the ‘scrollback’ section (diff)
config: ignore key/value pairs following an invalid section name
When we detected an invalid section name, we correctly logged this and warned the user. However, the internal state machine now had an invalid section enum value. This caused a crash when the next key/value pair was to be parsed and we tried to lookup which parser function to call. Closes #159.
Diffstat (limited to 'config.c')
-rw-r--r--config.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/config.c b/config.c
index c69af59d..ff5d6c59 100644
--- a/config.c
+++ b/config.c
@@ -1673,6 +1673,11 @@ parse_config_file(FILE *f, struct config *conf, const char *path, bool errors_ar
continue;
}
+ if (section >= SECTION_COUNT) {
+ /* Last section name was invalid; ignore all keys in it */
+ continue;
+ }
+
char *key = strtok(key_value, "=");
if (key == NULL) {
LOG_AND_NOTIFY_ERR("%s:%d: syntax error: no key specified", path, lineno);
@@ -1711,6 +1716,8 @@ parse_config_file(FILE *f, struct config *conf, const char *path, bool errors_ar
LOG_DBG("section=%s, key='%s', value='%s', comment='%s'",
section_info[section].name, key, value, comment);
+ assert(section >= 0 && section < SECTION_COUNT);
+
parser_fun_t section_parser = section_info[section].fun;
assert(section_parser != NULL);