diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2021-07-30 12:47:45 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2021-07-30 12:57:35 +0000 |
| commit | 7cfa48f369403d86dda2944511df0c23ce3dabd0 (patch) | |
| tree | 6ee9e36daea90e02926a2bf83be7dbac91406549 | |
| parent | config: include: add support for ~-expansion (diff) | |
config: include: handle get_user_home_dir() returning NULL
| -rw-r--r-- | config.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -650,6 +650,13 @@ parse_section_main(const char *key, const char *value, struct config *conf, if (value[0] == '~' && value[1] == '/') { const char *home_dir = get_user_home_dir(); + if (home_dir == NULL) { + LOG_AND_NOTIFY_ERRNO( + "%s:%d: [default]: include: %s: failed to expand '~'", + path, lineno, value); + return false; + } + int chars = snprintf(NULL, 0, "%s/%s", home_dir, &value[2]); _include_path = malloc(chars + 1); snprintf(_include_path, chars + 1, "%s/%s", home_dir, &value[2]); @@ -659,7 +666,7 @@ parse_section_main(const char *key, const char *value, struct config *conf, if (include_path[0] != '/') { LOG_AND_NOTIFY_ERR( - "%s:%d: [default]: %s: not an absolute path", + "%s:%d: [default]: include: %s: not an absolute path", path, lineno, include_path); free(_include_path); return false; @@ -669,7 +676,7 @@ parse_section_main(const char *key, const char *value, struct config *conf, if (include == NULL) { LOG_AND_NOTIFY_ERRNO( - "%s:%d: [default]: %s: failed to open", + "%s:%d: [default]: include: %s: failed to open", path, lineno, include_path); free(_include_path); return false; |
