diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2019-04-23 22:41:31 +0200 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2019-04-25 20:26:24 +0200 |
commit | f09e36acfe2db50e0452ba1e19b13f4395a8d704 (patch) | |
tree | 98128638131359eee2b91308284b965719388748 /src/blogc-make/ctx.c | |
parent | 4120e6adf557b01b8e43f8b5abe52c85602def64 (diff) | |
download | blogc-f09e36acfe2db50e0452ba1e19b13f4395a8d704.tar.gz blogc-f09e36acfe2db50e0452ba1e19b13f4395a8d704.tar.bz2 blogc-f09e36acfe2db50e0452ba1e19b13f4395a8d704.zip |
make: do not follow symlinks when resolving blogcfile path
Diffstat (limited to 'src/blogc-make/ctx.c')
-rw-r--r-- | src/blogc-make/ctx.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/blogc-make/ctx.c b/src/blogc-make/ctx.c index b8b7bb6..423b334 100644 --- a/src/blogc-make/ctx.c +++ b/src/blogc-make/ctx.c @@ -172,22 +172,21 @@ bm_ctx_new(bm_ctx_t *base, const char *settings_file, const char *argv0, if (settings_file == NULL || err == NULL || *err != NULL) return NULL; - char real_filename[PATH_MAX]; - if (NULL == realpath(settings_file, real_filename)) { - *err = bc_error_new_printf(BLOGC_MAKE_ERROR_SETTINGS, - "Failed to resolve settings file (%s): %s", settings_file, - strerror(errno)); + char *abs_filename = bm_abspath(settings_file, err); + if (*err != NULL) return NULL; - } size_t content_len; - char *content = bc_file_get_contents(real_filename, true, &content_len, + char *content = bc_file_get_contents(abs_filename, true, &content_len, err); - if (*err != NULL) + if (*err != NULL) { + free(abs_filename); return NULL; + } bm_settings_t *settings = bm_settings_parse(content, content_len, err); if (settings == NULL || *err != NULL) { + free(abs_filename); free(content); return NULL; } @@ -208,6 +207,7 @@ bm_ctx_new(bm_ctx_t *base, const char *settings_file, const char *argv0, atom_template = bm_atom_deploy(settings, err); atom_template_tmp = true; if (*err != NULL) { + free(abs_filename); bm_settings_free(settings); return NULL; } @@ -228,8 +228,9 @@ bm_ctx_new(bm_ctx_t *base, const char *settings_file, const char *argv0, } rv->settings = settings; - rv->settings_fctx = bm_filectx_new(rv, real_filename, NULL, NULL); - rv->root_dir = bc_strdup(dirname(real_filename)); + rv->settings_fctx = bm_filectx_new(rv, abs_filename, NULL, NULL); + rv->root_dir = bc_strdup(dirname(abs_filename)); + free(abs_filename); const char *output_dir = getenv("OUTPUT_DIR"); rv->short_output_dir = bc_strdup(output_dir != NULL ? output_dir : "_build"); |