[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/6] pki_gcrypt: Fix memory leak


* src/pki_gcrypt.c (b64decode_rsa_privatekey): Free 'v' on version
mismatch.
(b64decode_dsa_privatekey): Likewise.

Signed-off-by: Justus Winter <justus@xxxxxxxxxxx>
---
 src/pki_gcrypt.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/pki_gcrypt.c b/src/pki_gcrypt.c
index 16e4833..d75223f 100644
--- a/src/pki_gcrypt.c
+++ b/src/pki_gcrypt.c
@@ -471,6 +471,7 @@ static int b64decode_rsa_privatekey(const char *pkey, gcry_sexp_t *r,
 
   data = ssh_string_data(v);
   if (ssh_string_len(v) != 1 || data[0] != 0) {
+    ssh_string_free(v);
     ssh_buffer_free(buffer);
     return 0;
   }
@@ -547,6 +548,7 @@ static int b64decode_dsa_privatekey(const char *pkey, gcry_sexp_t *r, ssh_auth_c
 
   data = ssh_string_data(v);
   if (ssh_string_len(v) != 1 || data[0] != 0) {
+    ssh_string_free(v);
     ssh_buffer_free(buffer);
     return 0;
   }
-- 
2.1.4


References:
[PATCH 1/6] torture: Fix guardJustus Winter <justus@xxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org