diff options
author | M Hickford <mirth.hickford@gmail.com> | 2023-06-15 19:19:32 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-06-15 20:26:39 (GMT) |
commit | aeb21ce22eec112b37975443a160cb5418c6ec22 (patch) | |
tree | 8137c8aed31a7ee6b35c48ace8646c5e4126cfa5 /credential.c | |
parent | fe86abd7511a9a6862d5706c6fa1d9b57a63ba09 (diff) | |
download | git-aeb21ce22eec112b37975443a160cb5418c6ec22.zip git-aeb21ce22eec112b37975443a160cb5418c6ec22.tar.gz git-aeb21ce22eec112b37975443a160cb5418c6ec22.tar.bz2 |
credential: avoid erasing distinct password
Test that credential helpers do not erase a password distinct from the
input. Such calls can happen when multiple credential helpers are
configured.
Fixes for credential-cache and credential-store.
Signed-off-by: M Hickford <mirth.hickford@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'credential.c')
-rw-r--r-- | credential.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/credential.c b/credential.c index 023b59d..8825c6f 100644 --- a/credential.c +++ b/credential.c @@ -33,13 +33,14 @@ void credential_clear(struct credential *c) } int credential_match(const struct credential *want, - const struct credential *have) + const struct credential *have, int match_password) { #define CHECK(x) (!want->x || (have->x && !strcmp(want->x, have->x))) return CHECK(protocol) && CHECK(host) && CHECK(path) && - CHECK(username); + CHECK(username) && + (!match_password || CHECK(password)); #undef CHECK } @@ -102,7 +103,7 @@ static int match_partial_url(const char *url, void *cb) warning(_("skipping credential lookup for key: credential.%s"), url); else - matches = credential_match(&want, c); + matches = credential_match(&want, c, 0); credential_clear(&want); return matches; |