aboutsummaryrefslogtreecommitdiffstats
path: root/src/blogc-make
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2016-12-27 18:53:39 +0100
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2016-12-27 18:53:39 +0100
commitfe2e4eb61edc017017b95e57156b08f6a6b69e5a (patch)
tree00c73ace864518232b0c7160cb15365a44b69d15 /src/blogc-make
parenta913539c26ec3f34bbdf9474b77d528451b2042a (diff)
downloadblogc-fe2e4eb61edc017017b95e57156b08f6a6b69e5a.tar.gz
blogc-fe2e4eb61edc017017b95e57156b08f6a6b69e5a.tar.bz2
blogc-fe2e4eb61edc017017b95e57156b08f6a6b69e5a.zip
make: validate environment keys
Diffstat (limited to 'src/blogc-make')
-rw-r--r--src/blogc-make/settings.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/blogc-make/settings.c b/src/blogc-make/settings.c
index e2789dc..3df410f 100644
--- a/src/blogc-make/settings.c
+++ b/src/blogc-make/settings.c
@@ -97,7 +97,16 @@ bm_settings_parse(const char *content, size_t content_len, bc_error_t **err)
char **env = bc_config_list_keys(config, "environment");
if (env != NULL) {
for (size_t i = 0; env[i] != NULL; i++) {
- // FIXME: validate keys
+ for (size_t j = 0; env[i][j] != '\0'; j++) {
+ if (!((env[i][j] >= 'A' && env[i][j] <= 'Z') || env[i][j] == '_')) {
+ *err = bc_error_new_printf(BLOGC_MAKE_ERROR_SETTINGS,
+ "Invalid [environment] key: %s", env[i]);
+ bc_strv_free(env);
+ bm_settings_free(rv);
+ rv = NULL;
+ goto cleanup;
+ }
+ }
bc_trie_insert(rv->env, env[i],
bc_strdup(bc_config_get(config, "environment", env[i])));
}