summaryrefslogtreecommitdiffstats
path: root/core/git-access.c
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-01-12 18:54:27 +0100
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2018-01-13 21:55:33 +0100
commitdaede13571cd528b3cb054484a626d32326d3178 (patch)
treec2b4e5e7085dd7ec43cded1c5648ddc5a121b9f3 /core/git-access.c
parentde49f2484f108b725ad239a66352a42c63fb2070 (diff)
downloadsubsurface-daede13571cd528b3cb054484a626d32326d3178.tar.gz
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>
Diffstat (limited to 'core/git-access.c')
-rw-r--r--core/git-access.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/core/git-access.c b/core/git-access.c
index 2503abce6..8a0b916e5 100644
--- a/core/git-access.c
+++ b/core/git-access.c
@@ -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);
}