mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
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.
This commit is contained in:
parent
4ac5df079a
commit
b1bdc2d4c1
2 changed files with 9 additions and 0 deletions
|
|
@ -50,6 +50,8 @@
|
|||
that it is (much) slower compared to previous foot versions. Use the
|
||||
**scrollback.multiplier** option in `foot.ini` if you find the new
|
||||
speed too slow (https://codeberg.org/dnkl/foot/issues/144).
|
||||
* Crash when `foot.ini` contains an invalid section name
|
||||
(https://codeberg.org/dnkl/foot/issues/159).
|
||||
|
||||
|
||||
### Security
|
||||
|
|
|
|||
7
config.c
7
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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue