changeset 1058:063c38ea622b

Fix some memory leaks in ecc code
author Matt Johnston <matt@ucc.asn.au>
date Sun, 01 Mar 2015 22:44:36 +0800
parents fd3712d1ff7f
children a64ef3c2b371
files ecc.c ecdsa.c signkey.c
diffstat 3 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/ecc.c	Sat Feb 28 23:49:39 2015 +0800
+++ b/ecc.c	Sun Mar 01 22:44:36 2015 +0800
@@ -86,11 +86,6 @@
 {
 	mp_int *prime, *b, *t1, *t2;
 	int err;
-
-	prime = m_malloc(sizeof(mp_int));
-	b = m_malloc(sizeof(mp_int));
-	t1 = m_malloc(sizeof(mp_int));
-	t2 = m_malloc(sizeof(mp_int));
 	
 	m_mp_alloc_init_multi(&prime, &b, &t1, &t2, NULL);
 	
--- a/ecdsa.c	Sat Feb 28 23:49:39 2015 +0800
+++ b/ecdsa.c	Sun Mar 01 22:44:36 2015 +0800
@@ -409,7 +409,7 @@
 out:
 	ltc_ecc_del_point(mG);
 	ltc_ecc_del_point(mQ);
-	mp_clear_multi(r, s, v, w, u1, u2, p, e, m, NULL);
+	ltc_deinit_multi(r, s, v, w, u1, u2, p, e, m, NULL);
 	if (mp != NULL) { 
 		ltc_mp.montgomery_deinit(mp);
 	}
--- a/signkey.c	Sat Feb 28 23:49:39 2015 +0800
+++ b/signkey.c	Sun Mar 01 22:44:36 2015 +0800
@@ -187,6 +187,7 @@
 		if (eck) {
 			if (*eck) {
 				ecc_free(*eck);
+				m_free(*eck);
 				*eck = NULL;
 			}
 			*eck = buf_get_ecdsa_pub_key(buf);
@@ -255,6 +256,7 @@
 		if (eck) {
 			if (*eck) {
 				ecc_free(*eck);
+				m_free(*eck);
 				*eck = NULL;
 			}
 			*eck = buf_get_ecdsa_priv_key(buf);
@@ -355,18 +357,21 @@
 #ifdef DROPBEAR_ECC_256
 	if (key->ecckey256) {
 		ecc_free(key->ecckey256);
+		m_free(key->ecckey256);
 		key->ecckey256 = NULL;
 	}
 #endif
 #ifdef DROPBEAR_ECC_384
 	if (key->ecckey384) {
 		ecc_free(key->ecckey384);
+		m_free(key->ecckey384);
 		key->ecckey384 = NULL;
 	}
 #endif
 #ifdef DROPBEAR_ECC_521
 	if (key->ecckey521) {
 		ecc_free(key->ecckey521);
+		m_free(key->ecckey521);
 		key->ecckey521 = NULL;
 	}
 #endif