mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-09 15:00:04 +00:00
cred: Check for null values when getting key from memory
The public key field is optional and as such can take NULL. Account for that and do not call strlen() on NULL values. Also assert() for non-NULL values of username & private key.
This commit is contained in:
parent
f7142b5e4a
commit
2629fc874d
@ -374,12 +374,15 @@ static int _git_ssh_authenticate_session(
|
|||||||
case GIT_CREDTYPE_SSH_MEMORY: {
|
case GIT_CREDTYPE_SSH_MEMORY: {
|
||||||
git_cred_ssh_key *c = (git_cred_ssh_key *)cred;
|
git_cred_ssh_key *c = (git_cred_ssh_key *)cred;
|
||||||
|
|
||||||
|
assert(c->username);
|
||||||
|
assert(c->privatekey);
|
||||||
|
|
||||||
rc = libssh2_userauth_publickey_frommemory(
|
rc = libssh2_userauth_publickey_frommemory(
|
||||||
session,
|
session,
|
||||||
c->username,
|
c->username,
|
||||||
strlen(c->username),
|
strlen(c->username),
|
||||||
c->publickey,
|
c->publickey,
|
||||||
strlen(c->publickey),
|
c->publickey ? strlen(c->publickey) : 0,
|
||||||
c->privatekey,
|
c->privatekey,
|
||||||
strlen(c->privatekey),
|
strlen(c->privatekey),
|
||||||
c->passphrase);
|
c->passphrase);
|
||||||
|
Loading…
Reference in New Issue
Block a user