From 905cf9c01879870074034614fe0dcaeda19f2509 Mon Sep 17 00:00:00 2001 From: toddouska Date: Wed, 31 Oct 2012 12:54:56 -0700 Subject: [PATCH] fix valgrind warnings from yesterday changes --- ctaocrypt/src/asn.c | 14 +++++++++----- ctaocrypt/src/rsa.c | 2 +- ctaocrypt/test/test.c | 2 ++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/ctaocrypt/src/asn.c b/ctaocrypt/src/asn.c index 07e83c459..6db28fd21 100644 --- a/ctaocrypt/src/asn.c +++ b/ctaocrypt/src/asn.c @@ -4082,6 +4082,7 @@ int CyaSSL_PemCertToDer(const char* fileName, unsigned char* derBuf, int derSz); /* Set cert issuer from issuerFile in PEM */ int SetIssuer(Cert* cert, const char* issuerFile) { + int ret; int derSz; byte* der = (byte*)XMALLOC(EIGHTK_BUF, NULL, DYNAMIC_TYPE_CERT); @@ -4091,16 +4092,17 @@ int SetIssuer(Cert* cert, const char* issuerFile) } derSz = CyaSSL_PemCertToDer(issuerFile, der, EIGHTK_BUF); cert->selfSigned = 0; - + ret = SetNameFromCert(&cert->issuer, der, derSz); XFREE(der, NULL, DYNAMIC_TYPE_CERT); - return SetNameFromCert(&cert->issuer, der, derSz); + return ret; } /* Set cert subject from subjectFile in PEM */ int SetSubject(Cert* cert, const char* subjectFile) { + int ret; int derSz; byte* der = (byte*)XMALLOC(EIGHTK_BUF, NULL, DYNAMIC_TYPE_CERT); @@ -4109,10 +4111,10 @@ int SetSubject(Cert* cert, const char* subjectFile) return MEMORY_E; } derSz = CyaSSL_PemCertToDer(subjectFile, der, EIGHTK_BUF); - + ret = SetNameFromCert(&cert->subject, der, derSz); XFREE(der, NULL, DYNAMIC_TYPE_CERT); - return SetNameFromCert(&cert->subject, der, derSz); + return ret; } @@ -4121,6 +4123,7 @@ int SetSubject(Cert* cert, const char* subjectFile) /* Set atl names from file in PEM */ int SetAltNames(Cert* cert, const char* file) { + int ret; int derSz; byte* der = (byte*)XMALLOC(EIGHTK_BUF, NULL, DYNAMIC_TYPE_CERT); @@ -4129,9 +4132,10 @@ int SetAltNames(Cert* cert, const char* file) return MEMORY_E; } derSz = CyaSSL_PemCertToDer(file, der, EIGHTK_BUF); + ret = SetAltNamesFromCert(cert, der, derSz); XFREE(der, NULL, DYNAMIC_TYPE_CERT); - return SetAltNamesFromCert(cert, der, derSz); + return ret; } #endif /* CYASSL_ALT_NAMES */ diff --git a/ctaocrypt/src/rsa.c b/ctaocrypt/src/rsa.c index 5a454babd..a84b559c7 100644 --- a/ctaocrypt/src/rsa.c +++ b/ctaocrypt/src/rsa.c @@ -498,7 +498,7 @@ int MakeRsaKey(RsaKey* key, int size, long e, RNG* rng) err = mp_init_multi(&key->n, &key->e, &key->d, &key->p, &key->q, NULL); if (err == MP_OKAY) - err = mp_init_multi(&key->dP, &key->dP, &key->u, NULL, NULL, NULL); + err = mp_init_multi(&key->dP, &key->dQ, &key->u, NULL, NULL, NULL); if (err == MP_OKAY) err = mp_sub_d(&p, 1, &tmp2); /* tmp2 = p-1 */ diff --git a/ctaocrypt/test/test.c b/ctaocrypt/test/test.c index ae6b14f3f..b4711c098 100644 --- a/ctaocrypt/test/test.c +++ b/ctaocrypt/test/test.c @@ -1679,6 +1679,7 @@ int rsa_test(void) fclose(pemFile); free(pem); free(derCert); + FreeRsaKey(&caKey); } #ifdef HAVE_NTRU { @@ -1795,6 +1796,7 @@ int rsa_test(void) fclose(ntruPrivFile); free(pem); free(derCert); + FreeRsaKey(&caKey); } #endif /* HAVE_NTRU */ #endif /* CYASSL_CERT_GEN */