comparison signkey.c @ 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 0da8ba489c23
children c45d65392c1a
comparison
equal deleted inserted replaced
1053:fd3712d1ff7f 1058:063c38ea622b
185 if (signkey_is_ecdsa(keytype)) { 185 if (signkey_is_ecdsa(keytype)) {
186 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, keytype); 186 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, keytype);
187 if (eck) { 187 if (eck) {
188 if (*eck) { 188 if (*eck) {
189 ecc_free(*eck); 189 ecc_free(*eck);
190 m_free(*eck);
190 *eck = NULL; 191 *eck = NULL;
191 } 192 }
192 *eck = buf_get_ecdsa_pub_key(buf); 193 *eck = buf_get_ecdsa_pub_key(buf);
193 if (*eck) { 194 if (*eck) {
194 ret = DROPBEAR_SUCCESS; 195 ret = DROPBEAR_SUCCESS;
253 if (signkey_is_ecdsa(keytype)) { 254 if (signkey_is_ecdsa(keytype)) {
254 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, keytype); 255 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, keytype);
255 if (eck) { 256 if (eck) {
256 if (*eck) { 257 if (*eck) {
257 ecc_free(*eck); 258 ecc_free(*eck);
259 m_free(*eck);
258 *eck = NULL; 260 *eck = NULL;
259 } 261 }
260 *eck = buf_get_ecdsa_priv_key(buf); 262 *eck = buf_get_ecdsa_priv_key(buf);
261 if (*eck) { 263 if (*eck) {
262 ret = DROPBEAR_SUCCESS; 264 ret = DROPBEAR_SUCCESS;
353 #endif 355 #endif
354 #ifdef DROPBEAR_ECDSA 356 #ifdef DROPBEAR_ECDSA
355 #ifdef DROPBEAR_ECC_256 357 #ifdef DROPBEAR_ECC_256
356 if (key->ecckey256) { 358 if (key->ecckey256) {
357 ecc_free(key->ecckey256); 359 ecc_free(key->ecckey256);
360 m_free(key->ecckey256);
358 key->ecckey256 = NULL; 361 key->ecckey256 = NULL;
359 } 362 }
360 #endif 363 #endif
361 #ifdef DROPBEAR_ECC_384 364 #ifdef DROPBEAR_ECC_384
362 if (key->ecckey384) { 365 if (key->ecckey384) {
363 ecc_free(key->ecckey384); 366 ecc_free(key->ecckey384);
367 m_free(key->ecckey384);
364 key->ecckey384 = NULL; 368 key->ecckey384 = NULL;
365 } 369 }
366 #endif 370 #endif
367 #ifdef DROPBEAR_ECC_521 371 #ifdef DROPBEAR_ECC_521
368 if (key->ecckey521) { 372 if (key->ecckey521) {
369 ecc_free(key->ecckey521); 373 ecc_free(key->ecckey521);
374 m_free(key->ecckey521);
370 key->ecckey521 = NULL; 375 key->ecckey521 = NULL;
371 } 376 }
372 #endif 377 #endif
373 #endif 378 #endif
374 379