diff options
| author | Junio C Hamano <gitster@pobox.com> | 2024-06-28 15:53:16 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-06-28 15:53:17 -0700 |
| commit | ce75d32b99e7edd4ca7a99f376940b56d6c7ae0f (patch) | |
| tree | 74bebfe2611eb06a5b28852b70ab28bc39b103bf /setup.c | |
| parent | 7b7db54b8319aa4f31348debb4bd9b838753aa8c (diff) | |
| parent | 313eec177ad010048b399d6fd14de871b517f7e3 (diff) | |
| download | git-ce75d32b99e7edd4ca7a99f376940b56d6c7ae0f.tar.xz | |
Merge branch 'jc/safe-directory-leading-path' into maint-2.45
The safe.directory configuration knob has been updated to
optionally allow leading path matches.
* jc/safe-directory-leading-path:
safe.directory: allow "lead/ing/path/*" match
Diffstat (limited to 'setup.c')
| -rw-r--r-- | setup.c | 20 |
1 files changed, 14 insertions, 6 deletions
@@ -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; + const char *allowed = NULL; - if (!git_config_pathname(&interpolated, key, value) && - !fspathcmp(data->path, interpolated ? interpolated : value)) - data->is_safe = 1; - - free((char *)interpolated); + 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; |
