deps/libgit2/src/libgit2/transports/auth.c

filter: Statementstmt 0.0% 0 / 27 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 33 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« deps/libgit2/src/libgit2/trace.h ↑ Summary deps/libgit2/src/libgit2/transports/credential.c »
1 /*
2 * Copyright (C) the libgit2 contributors. All rights reserved.
3 *
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
6 */
7  
8 #include "auth.h"
9  
10 #include "git2/sys/credential.h"
11  
12 0 static int basic_next_token(
13 git_str *out,
14 git_http_auth_context *ctx,
15 git_credential *c)
16 {
17 git_credential_userpass_plaintext *cred;
18 0 git_str raw = GIT_STR_INIT;
19 0 int error = GIT_EAUTH;
20  
21 0 GIT_UNUSED(ctx);
22  
23 0 ▶ if (c->credtype != GIT_CREDENTIAL_USERPASS_PLAINTEXT) {
Branch: 1 branch
BranchTrueFalseTotal
if (c->credtype != GIT_CREDENTIAL_USERPASS_PLAINTEXT) { 0 0 0
24 0 git_error_set(GIT_ERROR_INVALID, "invalid credential type for basic auth");
25 0 goto on_error;
26 }
27  
28 0 cred = (git_credential_userpass_plaintext *)c;
29  
30 0 git_str_printf(&raw, "%s:%s", cred->username, cred->password);
31  
32 0 if (git_str_oom(&raw) ||
33 0 ▶ git_str_puts(out, "Basic ") < 0 ||
Branch: 1 branch
BranchTrueFalseTotal
git_str_puts(out, "Basic ") < 0 || 0 0 0
34 0 git_str_encode_base64(out, git_str_cstr(&raw), raw.size) < 0)
35 0 goto on_error;
36  
37 0 error = 0;
38  
39 0 on_error:
40 0 ▶ if (raw.size)
Branch: 1 branch
BranchTrueFalseTotal
if (raw.size) 0 0 0
41 0 git__memzero(raw.ptr, raw.size);
42  
43 0 git_str_dispose(&raw);
44 0 return error;
45 }
46  
47 static git_http_auth_context basic_context = {
48 GIT_HTTP_AUTH_BASIC,
49 GIT_CREDENTIAL_USERPASS_PLAINTEXT,
50 0,
51 NULL,
52 basic_next_token,
53 NULL,
54 NULL
55 };
56  
57 0 int git_http_auth_basic(
58 git_http_auth_context **out, const git_net_url *url)
59 {
60 0 GIT_UNUSED(url);
61  
62 0 *out = &basic_context;
63 0 return 0;
64 }
65  
66 0 int git_http_auth_dummy(
67 git_http_auth_context **out, const git_net_url *url)
68 {
69 0 GIT_UNUSED(url);
70  
71 0 *out = NULL;
72 0 return GIT_PASSTHROUGH;
73 }
74  
« deps/libgit2/src/libgit2/trace.h ↑ Summary deps/libgit2/src/libgit2/transports/credential.c »