summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-11-15 03:05:03 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-11-15 03:05:03 (GMT)
commit558d8568dfc92c4675495ab5cb7ef5d0655f88f8 (patch)
treef48f81ce8f3b64656d6e99376e20aebeb59fd1a4 /contrib
parent40bc898103359e1c2013585b2e043f556c23e15b (diff)
parent601e1e7897022b1f166c81e58c95e9afa06cac25 (diff)
downloadgit-558d8568dfc92c4675495ab5cb7ef5d0655f88f8.zip
git-558d8568dfc92c4675495ab5cb7ef5d0655f88f8.tar.gz
git-558d8568dfc92c4675495ab5cb7ef5d0655f88f8.tar.bz2
Merge branch 'js/wincred-empty-cred' into maint
MinGW updates. * js/wincred-empty-cred: wincred: handle empty username/password correctly t0302: check helper can handle empty credentials
Diffstat (limited to 'contrib')
-rw-r--r--contrib/credential/wincred/git-credential-wincred.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/contrib/credential/wincred/git-credential-wincred.c b/contrib/credential/wincred/git-credential-wincred.c
index 0061340..86518cd 100644
--- a/contrib/credential/wincred/git-credential-wincred.c
+++ b/contrib/credential/wincred/git-credential-wincred.c
@@ -94,6 +94,12 @@ static WCHAR *wusername, *password, *protocol, *host, *path, target[1024];
static void write_item(const char *what, LPCWSTR wbuf, int wlen)
{
char *buf;
+
+ if (!wbuf || !wlen) {
+ printf("%s=\n", what);
+ return;
+ }
+
int len = WideCharToMultiByte(CP_UTF8, 0, wbuf, wlen, NULL, 0, NULL,
FALSE);
buf = xmalloc(len);
@@ -160,7 +166,7 @@ static int match_part_last(LPCWSTR *ptarget, LPCWSTR want, LPCWSTR delim)
static int match_cred(const CREDENTIALW *cred)
{
LPCWSTR target = cred->TargetName;
- if (wusername && wcscmp(wusername, cred->UserName))
+ if (wusername && wcscmp(wusername, cred->UserName ? cred->UserName : L""))
return 0;
return match_part(&target, L"git", L":") &&
@@ -183,7 +189,7 @@ static void get_credential(void)
for (i = 0; i < num_creds; ++i)
if (match_cred(creds[i])) {
write_item("username", creds[i]->UserName,
- wcslen(creds[i]->UserName));
+ creds[i]->UserName ? wcslen(creds[i]->UserName) : 0);
write_item("password",
(LPCWSTR)creds[i]->CredentialBlob,
creds[i]->CredentialBlobSize / sizeof(WCHAR));