aboutsummaryrefslogtreecommitdiffstats
path: root/setup.c
diff options
context:
space:
mode:
Diffstat (limited to 'setup.c')
-rw-r--r--setup.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/setup.c b/setup.c
index 15abbaf21a..8a5242184b 100644
--- a/setup.c
+++ b/setup.c
@@ -1177,13 +1177,21 @@ static int safe_directory_cb(const char *key, const char *value,
} else if (!strcmp(value, "*")) {
data->is_safe = 1;
} else {
- const char *interpolated = NULL;
-
- if (!git_config_pathname(&interpolated, key, value) &&
- !fspathcmp(data->path, interpolated ? interpolated : value))
- data->is_safe = 1;
-
- free((char *)interpolated);
+ const char *allowed = NULL;
+
+ if (!git_config_pathname(&allowed, key, value)) {
+ if (!allowed)
+ allowed = value;
+ if (ends_with(allowed, "/*")) {
+ size_t len = strlen(allowed);
+ if (!fspathncmp(allowed, data->path, len - 1))
+ data->is_safe = 1;
+ } else if (!fspathcmp(data->path, allowed)) {
+ data->is_safe = 1;
+ }
+ }
+ if (allowed != value)
+ free((char *)allowed);
}
return 0;