Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2020-04-19 06:48:05 +0300
committerJonathan Nieder <jrnieder@gmail.com>2020-04-20 02:10:57 +0300
commit24036686c4af84c9e84e486ef3debab6e6d8e6b5 (patch)
tree5a205d9cf0485377b22db673839bd1a3fc3865e3 /credential.c
parent73aafe9bc27585554181c58871a25e6d0f58a3dc (diff)
credential: parse URL without host as empty host, not unset
We may feed a URL like "cert:///path/to/cert.pem" into the credential machinery to get the key for a client-side certificate. That credential has no hostname field, which is about to be disallowed (to avoid confusion with protocols where a helper _would_ expect a hostname). This means as of the next patch, credential helpers won't work for unlocking certs. Let's fix that by doing two things: - when we parse a url with an empty host, set the host field to the empty string (asking only to match stored entries with an empty host) rather than NULL (asking to match _any_ host). - when we build a cert:// credential by hand, similarly assign an empty string It's the latter that is more likely to impact real users in practice, since it's what's used for http connections. But we don't have good infrastructure to test it. The url-parsing version will help anybody using git-credential in a script, and is easy to test. Signed-off-by: Jeff King <peff@peff.net> Reviewed-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Diffstat (limited to 'credential.c')
-rw-r--r--credential.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/credential.c b/credential.c
index eeeac3242e..d1bb71b41a 100644
--- a/credential.c
+++ b/credential.c
@@ -373,8 +373,7 @@ int credential_from_url_gently(struct credential *c, const char *url,
if (proto_end - url > 0)
c->protocol = xmemdupz(url, proto_end - url);
- if (slash - host > 0)
- c->host = url_decode_mem(host, slash - host);
+ c->host = url_decode_mem(host, slash - host);
/* Trim leading and trailing slashes from path */
while (*slash == '/')
slash++;