mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Fix leak(s) in core/git-access.c
The libgit2 functions git_cred_ssh_key_new() and git_cred_userpass_plaintext_new() copy their arguments. Therefore, free the string arguments or don't copy them in the first place. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
de49f2484f
commit
daede13571
1 changed files with 6 additions and 4 deletions
|
@ -204,10 +204,12 @@ int credential_ssh_cb(git_cred **out,
|
|||
return GIT_EUSER;
|
||||
}
|
||||
|
||||
const char *priv_key = format_string("%s/%s", system_default_directory(), "ssrf_remote.key");
|
||||
const char *passphrase = prefs.cloud_storage_password ? strdup(prefs.cloud_storage_password) : strdup("");
|
||||
char *priv_key = format_string("%s/%s", system_default_directory(), "ssrf_remote.key");
|
||||
const char *passphrase = prefs.cloud_storage_password ? prefs.cloud_storage_password : "";
|
||||
|
||||
return git_cred_ssh_key_new(out, username_from_url, NULL, priv_key, passphrase);
|
||||
int res = git_cred_ssh_key_new(out, username_from_url, NULL, priv_key, passphrase);
|
||||
free(priv_key);
|
||||
return res;
|
||||
}
|
||||
|
||||
int credential_https_cb(git_cred **out,
|
||||
|
@ -228,7 +230,7 @@ int credential_https_cb(git_cred **out,
|
|||
}
|
||||
|
||||
const char *username = prefs.cloud_storage_email_encoded;
|
||||
const char *password = prefs.cloud_storage_password ? strdup(prefs.cloud_storage_password) : strdup("");
|
||||
const char *password = prefs.cloud_storage_password ? prefs.cloud_storage_password : "";
|
||||
|
||||
return git_cred_userpass_plaintext_new(out, username, password);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue