Re: [PATCH v3 2/3] safe.directory: normalize the configured path
- From
Jeff King <peff@peff.net>
- Date
- Jul 30, 2024, 07:43 UTC
- Message-ID
- <20240730074307.GB562212@coredump.intra.peff.net>
- In-Reply-To
- <20240730011004.4030246-3-gitster@pobox.com>
On Mon, Jul 29, 2024 at 06:10:03PM -0700, Junio C Hamano wrote:
Show 7 quoted lines
> @@ -1236,14 +1236,43 @@ static int safe_directory_cb(const char *key, const char *value,
>
> if (!git_config_pathname(&allowed, key, value)) {
> const char *check = allowed ? allowed : value;
> - if (ends_with(check, "/*")) {
> - size_t len = strlen(check);
> - if (!fspathncmp(check, data->path, len - 1))BTW, one oddity I noticed in the existing code:
Under what circumstances will "allowed" be NULL in that ternary? I think if git_config_pathname() returns non-zero, then we called interpolate_path(). It can return NULL, but in that case git_config_pathname() will die(). We might change that later, but then I'd expect it to return non-zero. So I suspect the whole "check" variable could just be dropped in favor of using "allowed".
Obviously not new in your patch, but maybe worth fixing while in the area? I think it comes from an evil merge in b8bdb2f283 (Merge branch 'jc/safe-directory-leading-path', 2024-06-12).
-Peff