aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2015-05-04 16:21:04 +0200
committerAndreas Schneider <asn@cryptomilk.org>2015-05-04 17:54:01 +0200
commitb1a3f4ee33a300ae446eccb024f472e54ac9361a (patch)
tree2ff2208b8aab56b894af3488a582e07756fe5410
parent05498e0e33f575948026316b560666213535d5ed (diff)
downloadlibssh-b1a3f4ee33a300ae446eccb024f472e54ac9361a.tar.gz
libssh-b1a3f4ee33a300ae446eccb024f472e54ac9361a.tar.xz
libssh-b1a3f4ee33a300ae446eccb024f472e54ac9361a.zip
pki_container: Fix a memory leak
CID: #1267980 Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r--src/pki_container_openssh.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/pki_container_openssh.c b/src/pki_container_openssh.c
index c276f486..bfc6f8d4 100644
--- a/src/pki_container_openssh.c
+++ b/src/pki_container_openssh.c
@@ -613,9 +613,16 @@ ssh_string ssh_pki_openssh_privkey_export(const ssh_key privkey,
}
if (to_encrypt){
- ssh_buffer kdf_buf = ssh_buffer_new();
+ ssh_buffer kdf_buf;
+
+ kdf_buf = ssh_buffer_new();
+ if (kdf_buf == NULL) {
+ goto error;
+ }
+
salt = ssh_string_new(16);
- if (kdf_buf == NULL || salt == NULL){
+ if (salt == NULL){
+ ssh_buffer_free(kdf_buf);
goto error;
}
ssh_get_random(ssh_string_data(salt),16, 0);