mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-11 18:50:28 +09:00
known_hosts: Fix a memleak.
This commit is contained in:
@@ -613,13 +613,15 @@ int ssh_write_knownhost(ssh_session session) {
|
|||||||
/* openssh uses a different format for ssh-rsa1 keys.
|
/* openssh uses a different format for ssh-rsa1 keys.
|
||||||
Be compatible --kv */
|
Be compatible --kv */
|
||||||
rc = ssh_pki_export_pubkey_rsa1(key, host, buffer, sizeof(buffer));
|
rc = ssh_pki_export_pubkey_rsa1(key, host, buffer, sizeof(buffer));
|
||||||
|
ssh_key_free(key);
|
||||||
|
SAFE_FREE(host);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
fclose(file);
|
fclose(file);
|
||||||
SAFE_FREE(host);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
rc = ssh_pki_export_pubkey_base64(key, &b64_key);
|
rc = ssh_pki_export_pubkey_base64(key, &b64_key);
|
||||||
|
ssh_key_free(key);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
fclose(file);
|
fclose(file);
|
||||||
SAFE_FREE(host);
|
SAFE_FREE(host);
|
||||||
@@ -632,9 +634,9 @@ int ssh_write_knownhost(ssh_session session) {
|
|||||||
key->type_c,
|
key->type_c,
|
||||||
b64_key);
|
b64_key);
|
||||||
|
|
||||||
|
SAFE_FREE(host);
|
||||||
SAFE_FREE(b64_key);
|
SAFE_FREE(b64_key);
|
||||||
}
|
}
|
||||||
SAFE_FREE(host);
|
|
||||||
|
|
||||||
if (fwrite(buffer, strlen(buffer), 1, file) != 1 || ferror(file)) {
|
if (fwrite(buffer, strlen(buffer), 1, file) != 1 || ferror(file)) {
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|||||||
Reference in New Issue
Block a user